#include <stdio.h>
int main()
{
int year ,month,day,i=1;
printf("欢迎使用本程序,使用愉快\n") ;
while(i<10){
printf("请输入您需要计算的年\n");
scanf("%d",&year);
printf("请输入您需要计算的月\n");
scanf("%d",&month);
printf("请输入您需要计算的日\n");
scanf("%d",&day);
int sum,m;
if(year%400 != 0 && year%4 == 0){
printf("该年是闰年\n",&year);}
else{
printf("该年是平年\n",&year);}
switch(month)
{case 1:sum=day;
printf("该月共有31天\n");
break;
case 2:sum=31+day;
if(year%400 != 0 && year%4 == 0){
printf("该月共有29天\n",&year); }
else{
printf("该月共有28天\n",&year); }
break;
case 3:if(year%400 != 0 && year%4 == 0){
sum=31+29+day; }
else{
sum=31+28+day;}
printf("该月共有31天\n");
break;
case 4:sum=31+28+31+day;
printf("该月共有30天\n");
break;
case 5:sum=31+28+31+30+day;
printf("该月共有31天\n");
break;
case 6:sum=31+28+31+30+31+day;
printf("该月共有30天\n");
break;
case 7:sum=31+28+31+30+31+30+day;
printf("该月共有31天\n");
break;
case 8:sum=31+28+31+30+31+30+31+day;
printf("该月共有31天\n");
break;
case 9:sum=31+28+31+30+31+30+31+31+day;
printf("该月共有30天\n");
break;
case 10:sum=31+28+31+30+31+30+31+31+30+day;
printf("该月共有31天\n");
break;
case 11:sum=31+28+31+30+31+30+31+31+30+31+day;
printf("该月共有30天\n");
break;
case 12:sum=31+28+31+30+31+30+31+31+30+31+30+day;
printf("该月共有31天\n");
break; }
if(year%4==0&&year%100!=0||year%400==0)
m=1;
else
m=0;
if(m==1&&month>2)
sum++;
printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);
i++;}
return 0;
}
文章评论