commit dcd1447b1f696011e35043b154f7a5e356b72b83 Author: 18408000619@stu.hut.edu.cn <18408000619@stu.hut.edu.cn> Date: Tue Jan 8 09:13:03 2019 +0800 first commit diff --git a/zengguoqing/rili.cpp b/zengguoqing/rili.cpp new file mode 100644 index 0000000..708ac70 --- /dev/null +++ b/zengguoqing/rili.cpp @@ -0,0 +1,72 @@ +#include +int main() +{ + int i; + int year,month,day,sum,leap; + printf("1:查询某年某月有几天\n2:查询某日是一年中的第几天\n"); + printf("请输入选项:"); + scanf("%d",&i); + while(i){ + + switch(i) + {case 1: printf("输入年月:"); + scanf("%d%d",&year,&month); + switch(month) + { + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12:day=31;break; + case 4: + case 6: + case 9: + case 11:day=30;break; + case 2: + {if(year%400==0||(year%4==0&&year%100!=0)) + day=29; + else + day=28; + } + break; + default :day=-1; + } + if(day==-1) printf("ERROR"); + else + printf("%d年%d月有%d天",year,month,day); + return 0; + break; + case 2: int flag=0,le; + printf("输入年月日:"); + scanf("%d%d%d",&year,&month,&day); + switch(month) + { case 1:sum=0;break; + case 2:sum=31;break; + case 3:sum=59;break; + case 4:sum=90;break; + case 5:sum=120;break; + case 6:sum=151;break; + case 7:sum=181;break; + case 8:sum=212;break; + case 9:sum=243;break; + case 10:sum=273;break; + case 11:sum=304;break; + case 12:sum=334;break; + default:flag=1; + } + if(flag==0) + {sum=sum+day; + if(year%400==0||(year%4==0&&year%100!=0)) + le=1;else + le=0; + if(le=1&&month>2) + sum++; + printf("%d月%d日是%d年的第%d天",month,day,year,sum);return 0; + } break; + + }} + return 0; +} + diff --git a/zengguoqing/rili.exe b/zengguoqing/rili.exe new file mode 100644 index 0000000..6bba2d4 Binary files /dev/null and b/zengguoqing/rili.exe differ