第七章第2小题
#include <iostream>using namespace std;struct date{int year;int month;int days;};int main(){int days(date);date d1;cin>>d1.year;cin>>d1.month;cin>>d1.days;cout<<"您输入的时间是"<<d1.year<<"年"<<d1.month<<"月"<<d1.days<<"日"<<endl;cout<<"该日在本年中是第"<<days(d1)<<"天"<<endl;return 0;}int days(date d){int run(date);if (run(d)==1){switch(d.month){case 1:return d.days;break;case 2:return 31+d.days;break;case 3:return 60+d.days;break;case 4:return 91+d.days;break;case 5:return 121+d.days;break;case 6:return 152+d.days;break;case 7:return 182+d.days;break;case 8:return 213+d.days;break;case 9:return 244+d.days;break;case 10:return 274+d.days;break;case 11:return 305+d.days;break;case 12:return 335+d.days;break;}}else{switch(d.month){case 1:return d.days;break;case 2:return 31+d.days;break;case 3:return 59+d.days;break;case 4:return 90+d.days;break;case 5:return 120+d.days;break;case 6:return 151+d.days;break;case 7:return 181+d.days;break;case 8:return 212+d.days;break;case 9:return 243+d.days;break;case 10:return 273+d.days;break;case 11:return 304+d.days;break;case 12:return 334+d.days;break;}}}int run(date d){bool leap;if(d.year%4==0){if(d.year%100==0){if(d.year%400==0)leap=true;else leap=false;}elseleap=true;}elseleap=false;if(leap==true)return 1;else return 0;}