解题思路:
注意事项:
参考代码:
#include<iostream>
using namespace std;
struct date{
int year;
int month;
int day;
};
int main()
{
struct date time;
int days=0;
int a1[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int a2[12]={31,29,31,30,31,30,31,31,30,31,30,31};
cin>>time.year>>time.month>>time.day;
if((time.year%4==0&&time.year%100==0)||time.year%400==0){
for(int i=0;i<time.month-1;i++){
days+=a2[i];
}
days+=time.day;
}else{
for(int i=0;i<time.month-1;i++){
days+=a1[i];
}
days+=time.day;
}
cout<<days<<endl;
return 0;
}
0.0分
0 人评分