文章
61
粉丝
137
获赞
18
访问
38.4k
#include<bits/stdc++.h>
using namespace std;
bool runjudge(int year);
int main(){
int year, month, day;
int run[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
while(cin >> year >> month >> day){
if(runjudge(year))
run[2] = 29;
else run[2] = 28;
if(month >12 || month <= 0){
cout << "Input error!" << endl;
continue;
}
if(day > run[month] || day <= 0){
cout << "Input error!" << endl;
continue;
}
int sum = 0;
for(int i = 1; i < month; i++){
sum += run[i];
}
sum += day;
cout << sum << endl;
}
return 0;
}
bool runjudge(int year){
if(year % 4 == 0){
if(year % 100 == 0){
if(year % 400 == 0)
return true;
else return false ;
}else{
...
登录后发布评论
暂无评论,来抢沙发