#include <iostream> using namespace std; struct time { int year; int month; int day; int hour; int minite; int second; }; struct tim { int year; int month; int day; }; struct ti { int day; int hour; }; time stu; tim stu1; ti stu2; void this_year_day (time stu); void this_day_second(time stu); void this_year_second(time stu); void this_year_minite(tim stu1,int u); void this_year_minitee(ti stu2,int p); int sum; int main() { int a,b,c,d,e,f,u,p; cout<<"请输入一个时间(包括年,月,日,时,分,秒):"<<endl; cin>>a>>b>>c>>d>>e>>f; stu.year=a; stu.month=b; stu.day=c; stu.hour=d; stu.minite=e; stu.second=f; this_year_day(stu); this_day_second(stu); this_year_second(stu); cout<<"请输入一个时间"<<endl; cin>>u; this_year_minite(stu1,u); cout<<"请输入一个时间"<<endl; cin>>p; this_year_minitee(stu2,p); return 0; } void this_year_day (time stu) { int i,j,m,k,h; h=stu.year@0; i=stu.year%4,j=stu.year0; if (i==0 && j!=0 || h==0) { cout<<stu.year<<"是闰年"<<endl; for (m=1;m<=stu.month;m++) { if(stu.month==2) { sum=sum+28; continue; } k=m%2; if (k!=0 && stu.month<=7) //stu[1].month!=8 && stu[1].month!=10 && stu[1].month!=12 { sum=sum+31; continue; } if(stu.month!=8 && stu.month!=10 && stu.month!=12) { sum=sum+31; continue; } sum=sum+30; } sum=sum+stu.day; cout<<stu.day<<"在"<<stu.year<<"中是第"<<sum<<"天"<<endl; } else { cout<<stu.year<<"是平年"<<endl; for (m=1;m<=stu.month;m++) { if(stu.month==2) { sum=sum+29; continue; } k=m%2; if (k!=0 && stu.month<=7) //stu[1].month!=8 && stu[1].month!=10 && stu[1].month!=12 { sum=sum+31; continue; } if(stu.month!=8 && stu.month!=10 && stu.month!=12) { sum=sum+31; continue; } sum=sum+30; } sum=sum+stu.day; cout<<stu.day<<"在"<<stu.year<<"中是第"<<sum<<"天"<<endl; } return; } void this_day_second(time stu) { int i; i=stu.hour*60*60+stu.minite+stu.second; cout<<"这是这一年中的第"<<i<<"秒."<<endl; return; } void this_year_second(time stu) { int i; i=sum*24*60*60+stu.hour*60*60+stu.minite*60+stu.second; cout<<"这是这一年中的第"<<i<<"秒."<<endl; return; }
void this_year_minite(tim stu1,int u) { int m,t,h,n; if(stu.month==1 || stu.month==3 || stu.month==5 || stu.month==7 || stu.month==8 || stu.month==10 || stu.month==12) { m=stu.day+u; if(m>30) { n=m/30; t=n+stu.month; if(t>=12) { h=t/12; stu1.year=stu.year+h; stu1.month=t-12*h; stu1.day=m-n*30; } else { stu1.year=stu.year; stu1.month=t; stu1.day=m-n*30; } } else { stu1.year=stu.year; stu1.month=stu.month; stu1.day=stu.day+u; } } else { m=stu.day+u; if(m>31) { n=m/30; t=n+stu.month; if(t>=12) { h=t/12; stu1.year=stu.year+h; stu1.month=t-12*h; stu1.day=m-n*30; } else { stu1.year=stu.year; stu1.month=t; stu1.day=m-n*30; } } else { stu1.year=stu.year; stu1.month=stu.month; stu1.day=stu.day+u; } } cout<<u<<"天后是"<<stu1.year<<"年"<<stu1.month<<"月"<<stu1.day<<"日"<<endl; return; } void this_year_minitee(ti stu2,int p) { int m,t,n; m=p/60; m=m+stu.minite; if(m>60) { n=m/60; n=n+stu.hour; if(n>24) { t=n/24; stu2.day=stu.day+t; stu2.hour=n-t*24; } else { stu2.day=stu.day; stu2.hour=stu.hour+n; } } else { stu2.day=stu.day; stu2.hour=stu.hour; }
cout<<p<<"秒后是"<<stu2.day<<"日"<<stu2.hour<<"时"<<endl; return; }