first commit

master
commit dcd1447b1f

@ -0,0 +1,72 @@
#include<stdio.h>
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;
}

Binary file not shown.
Loading…
Cancel
Save