- #include <iostream>
- using namespace std;
- int main(){
- int year,month,day,n=0;
- int md[11] = {31,28,31,30,31,30,31,31,30,31,30};
- while(cin >> year >> month >> day){
- if((year%4==0) && (year%100!=0)){
- md[1] = 29;
- }else if((year%400==0)){
- md[1] = 29;
- }
- else{
- }
- if(month > 12 || day > md[month-1]){
- cout << "Error" << endl;
- }else{
- if(month > 1){
- for(int i = 0; i < month - 1; i++){
- n += md[i];
- }
- cout << "It is " << n + day << " days in " << year << endl;
- }else if(month == 1 && day == 1){
- cout << "It is " << day << " day in " << year << endl;
- }else if(month == 1 && day > 1){
- cout << "It is " << day << " days in " << year << endl;
- }
- }
- n = 0;
- md[1] = 28;
- }
- return 0;
- }
複製代碼 |