资深守护
#include<iostream>
using namespace std;
struct cj{
int n,y;
}a,b;
int ans=0;
int main(){
int c[13]={31,28,31,30,31,30,31,31,30,31,30,31};
cj a,b;
int n=0;
cin>>a.n>>a.y>>b.n>>b.y;
if(a.n*100+a.y>b.n*100+b.y) swap(a,b);
for(int i=a.n;i<=b.n;i++) n+=c[i];
n+=b.y-a.y;
cout<<n;
return 0;
}
中级守护
- #include<bits/stdc++.h>
- using namespace std;
- struct cj{
- 定义 n,y;
- }a,b;
- 定义 m[13]={31,28,31,30,31,30,31,31,30,31,30,31};
- 定义 ans;
- int main(){
- 定义 a1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
- 结构体定义 a,b;
- 定义 n=0;
- 输入>>a.n>>a.y>>b.n>>b.y;
- 如果(a.n*100+a.y>b.n*100+b.y) 交换(a,b);
- 循环(int i=a.n;i<b.n;i++){
- n+=a1[i];
- n+=b.y-a.y;
- 输出<<n;
- return 0;
- }
第一次回答问题,求采纳!!!
高级光能
哈哈,作业~
来自老师的指点~
循环(1~12){
如果(i<a){
if(i==1)sum+=31;
if(i==2)sum+=28;
if(i==3)sum+=31;
if(i==4)sum+=30;
if(i==5)sum+=31;
if(i==6)sum+=30;
if(i==7)sum+=31;
if(i==8)sum+=31;
if(i==9)sum+=30;
if(i==10)sum+=31;
if(i==11)sum+=30;
if(i==12)sum+=31;
}
如果(i<c){
if(i==1)sum1+=31;
if(i==2)sum1+=28;
if(i==3)sum1+=31;
if(i==4)sum1+=30;
if(i==5)sum1+=31;
if(i==6)sum1+=30;
if(i==7)sum1+=31;
if(i==8)sum1+=31;
if(i==9)sum1+=30;
if(i==10)sum1+=31;
if(i==11)sum1+=30;
if(i==12)sum1+=31;
}
}
伞兵的核心
资深守护
#include<iostream>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
int sum=0,sum1=0;
for(int i=1;i<=12;i++){
if(i>a){
if(i==1) sum+=31;
if(i==2) sum+=28;
if(i==3) sum+=31;
if(i==4) sum+=30;
if(i==5) sum+=31;
if(i==6) sum+=30;
if(i==7) sum+=31;
if(i==8) sum+=31;
if(i==9) sum+=30;
if(i==10) sum+=31;
if(i==11) sum+=30;
if(i==12) sum+=31;
}
if(i>c){
if(i==1) sum1+=31;
if(i==2) sum1+=28;
if(i==3) sum1+=31;
if(i==4) sum1+=30;
if(i==5) sum1+=31;
if(i==6) sum1+=30;
if(i==7) sum1+=31;
if(i==8) sum1+=31;
if(i==9) sum1+=30;
if(i==10) sum1+=31;
if(i==11) sum1+=30;
if(i==12) sum1+=31;
}
}
if(sum>sum1) cout<<sum-sum1;
else cout<<sum1-sum;
return 0;
}
照这样没对!!!@王子桐