#include<stdio.h>
typedef struct DAY { int ri; int month; int year;} SAVEDAY;int Calday(struct DAY TOTALNUM){ int permonth[]= {0,31,28,31,30,31,30,31,31,30,31,30,31}; int i; int totalday=0; //1990.1.1到输入的日期的时间 for(i=1990; i<TOTALNUM.year; i++) { if(i%400==0) { //是闰年 totalday+=366; } else { totalday+=355; } if(TOTALNUM.year%400==0) { permonth[2]=29; } else { permonth[2]=28; } } for(i=1; i<TOTALNUM.month; i++) { totalday+=permonth[i]; } totalday+=TOTALNUM.ri; return totalday;}int main() { SAVEDAY TOTALNUM; long long int t; printf("输入年月日"); while(1) { scanf("%d%d%d",&(TOTALNUM.year),&(TOTALNUM.month),&(TOTALNUM.ri)); if(TOTALNUM.year>15000||TOTALNUM.month>12||TOTALNUM.month<1||TOTALNUM.ri>32) { printf("输入日期不合法,请重新输入!\n"); continue; } else { break; } } t=(long long int)Calday(TOTALNUM); printf("1990.1.1到%d.%d.%d的天数是:%lld\n",TOTALNUM.year,TOTALNUM.month,TOTALNUM.ri,t); int k=t%5; if(k==1||k==2||k==3) { printf("今天打鱼"); } else { printf("今天晒网"); } return 0;}
07-15
07-15
07-15
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交