c语言《计算某一天是这一年的第几天》的程序
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{b=29;leap=1;}
else if(year%100==0&&year%400==0)
{leap=1;b=29;}
else
{leap=0;b=28;}/*此行结束闰年判断*/
switch(month)/*此行开始计算天数*/
{
case 1:num=day;break;
case 2:if(day>b)
}
else if(month==1||3||5||7||8||10||12)
{
if(day>31)
{printf("error in day\nplease input a right data\n");goto d;
}
else goto dd;
}
else if(month==4||6||9||11)
else
printf("the data is No.%d day in the whole year.\n",num);
system("pause");
}
{printf("error ቤተ መጻሕፍቲ ባይዱn day\nplease input a right data\n");goto d;
}
else num=a+day;break;
case 3:num=a+b+day;break;
case 4:num=2*a+b+day;break;
case 5:num=2*a+b+c+day;break;
}/*此行结束计算天数*/
if(num>366||num<=0)/*此行开始后期报错检验,对系统出现的未知错误进行报错*/
{printf("error in system\nplease input a right data or debug this program\n");goto d;
}/*此行结束后期报错检验*/
{
if(day>30)
{
printf("error in day\nplease input a right data\n");goto d;
}
else goto dd;
}/*此行结束前期报错检验*/
dd:if(year%4==0&&year%100!=0)/*此行开始判断是否为闰年,并给2月天数按情况赋值*/
case 11:num=6*a+b+3*c+day;break;
case 12:num=6*a+b+4*c+day;break;
default :printf("error in system\nplease input a right data or debug this program\n");goto d;
if(year<=0)/*从此行开始为前期报错检验,用于检验输入的日期是否有系统性错误*/
{printf("error in year\nplease input in a right data\n");goto d;
}
else if(month>=13||month<=0)
{printf("error in month\nplease input a right data\n");goto d;
case 6:num=3*a+b+c+day;break;
case 7:num=3*a+b+2*c+day;break;
case 8:num=4*a+b+2*c+day;break;
case 9:num=5*a+b+2*c+day;break;
case 10:num=5*a+b+3*c+day;break;
#include<stdio.h>/*此程序用于计算某年某月某日是这一年的第几天*/
void main()
{
int year,month,day,a=31,b,c=30,num,leap;
printf("please input year,month,day with keyboard\n");
d:scanf("%d,%d,%d",&year,&month,&day);
else if(year%100==0&&year%400==0)
{leap=1;b=29;}
else
{leap=0;b=28;}/*此行结束闰年判断*/
switch(month)/*此行开始计算天数*/
{
case 1:num=day;break;
case 2:if(day>b)
}
else if(month==1||3||5||7||8||10||12)
{
if(day>31)
{printf("error in day\nplease input a right data\n");goto d;
}
else goto dd;
}
else if(month==4||6||9||11)
else
printf("the data is No.%d day in the whole year.\n",num);
system("pause");
}
{printf("error ቤተ መጻሕፍቲ ባይዱn day\nplease input a right data\n");goto d;
}
else num=a+day;break;
case 3:num=a+b+day;break;
case 4:num=2*a+b+day;break;
case 5:num=2*a+b+c+day;break;
}/*此行结束计算天数*/
if(num>366||num<=0)/*此行开始后期报错检验,对系统出现的未知错误进行报错*/
{printf("error in system\nplease input a right data or debug this program\n");goto d;
}/*此行结束后期报错检验*/
{
if(day>30)
{
printf("error in day\nplease input a right data\n");goto d;
}
else goto dd;
}/*此行结束前期报错检验*/
dd:if(year%4==0&&year%100!=0)/*此行开始判断是否为闰年,并给2月天数按情况赋值*/
case 11:num=6*a+b+3*c+day;break;
case 12:num=6*a+b+4*c+day;break;
default :printf("error in system\nplease input a right data or debug this program\n");goto d;
if(year<=0)/*从此行开始为前期报错检验,用于检验输入的日期是否有系统性错误*/
{printf("error in year\nplease input in a right data\n");goto d;
}
else if(month>=13||month<=0)
{printf("error in month\nplease input a right data\n");goto d;
case 6:num=3*a+b+c+day;break;
case 7:num=3*a+b+2*c+day;break;
case 8:num=4*a+b+2*c+day;break;
case 9:num=5*a+b+2*c+day;break;
case 10:num=5*a+b+3*c+day;break;
#include<stdio.h>/*此程序用于计算某年某月某日是这一年的第几天*/
void main()
{
int year,month,day,a=31,b,c=30,num,leap;
printf("please input year,month,day with keyboard\n");
d:scanf("%d,%d,%d",&year,&month,&day);