|
运行环境: VS
#include<stdio.h>
void main()
{
int year;
int mouth;
int day;
int tianshu;
printf("*******************************************\n");
printf("请输入年:");
scanf("%d",&year);
printf("请输入月:");
scanf("%d",&mouth);
printf("请输入日:");
scanf("%d",&day);
printf("*******************************************\n");
if(year%4==0&&year%100!=0||year%400==0)
{
if(mouth==1)
{
tianshu=day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==2)
{
tianshu=day+31;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==3)
{
tianshu=31+29+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==4)
{
tianshu=31+29+31+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==5)
{
tianshu=31+29+31+30+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==6)
{
tianshu=31+29+31+30+31+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==7)
{
tianshu=31+29+31+30+31+30+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==8)
{
tianshu=31+29+31+30+31+30+31+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==9)
{
tianshu=31+29+31+30+31+30+31+31+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==10)
{
tianshu=31+29+31+30+31+30+31+31+30+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==11)
{
tianshu=31+29+31+30+31+30+31+31+30+31+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==12)
{
tianshu=31+29+31+30+31+30+31+31+30+31+30+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else
{
printf("输入错误!!!\n");
}
}
else
{
if(mouth==1)
{
tianshu=day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==2)
{
tianshu=day+31;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==3)
{
tianshu=31+28+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==4)
{
tianshu=31+28+31+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==5)
{
tianshu=31+28+31+30+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==6)
{
tianshu=31+28+31+30+31+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==7)
{
tianshu=31+28+31+30+31+30+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==8)
{
tianshu=31+28+31+30+31+30+31+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==9)
{
tianshu=31+28+31+30+31+30+31+31+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==10)
{
tianshu=31+28+31+30+31+30+31+31+30+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==11)
{
tianshu=31+28+31+30+31+30+31+31+30+31+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else if(mouth==12)
{
tianshu=31+28+31+30+31+30+31+31+30+31+30+day;
printf("这一天是%d年的第%d天\n",year,tianshu);
}
else
{
printf("输入错误!!!\n");
}
}
} |
|