偷空气
2018-08-24 15:48
#include <stdio.h>
int main()
{
int year = 2008;
int month = 8;
int day = 8;
int date,i;
if(year%4==0||year%100==0&&year%400!=0)i=1;
else i=0;
switch(month)
{
case 1:
date=day;
break;
case 2:
date=31+day;
break;
case 3:
date=31+28+day;
break;
case 4:
date=31+28+31+day;
break;
case 5:
date=31+28+31+30+day;
break;
case 6:
date=31+28+31+30+31+day;
break;
case 7:
date=31+28+31+30+31+30+day;
break;
case 8:
date=31+28+31+30+31+30+31+day;
break;
case 9:
date=31+28+31+30+31+30+31+31+day;
break;
case 10:
date=31+28+31+30+31+30+31+31+30+day;
break;
case 11:
date=31+28+31+30+31+30+31+31+30+31+day;
break;
case 12:
date=31+28+31+30+31+30+31+31+30+31+30+day;
break;
if(i==1) date+=1;
}
printf("%d年%d月%d日是这一年的第%d天",year,month,day,date);
return 0;
}
#include <stdio.h>
int main()
{
int year = 2008;
int month = 8;
int day = 8;
int date,i;
if(year%4==0||year%100==0&&year%400!=0)i=1;
else i=0;
switch(month)
{
case 1:
date=day;
break;
case 2:
date=31+day;
break;
case 3:
date=31+28+day;
break;
case 4:
date=31+28+31+day;
break;
case 5:
date=31+28+31+30+day;
break;
case 6:
date=31+28+31+30+31+day;
break;
case 7:
date=31+28+31+30+31+30+day;
break;
case 8:
date=31+28+31+30+31+30+31+day;
break;
case 9:
date=31+28+31+30+31+30+31+31+day;
break;
case 10:
date=31+28+31+30+31+30+31+31+30+day;
break;
case 11:
date=31+28+31+30+31+30+31+31+30+31+day;
break;
case 12:
date=31+28+31+30+31+30+31+31+30+31+30+day;
break; ///// 这里的分号改成英文的,你原本是汉语的
} //////// 大括号的位置改一下
if(i==1) date+=1;
// }
printf("%d年%d月%d日是这一年的第%d天",year,month,day,date);
return 0;
}
C语言入门
926209 学习 · 20797 问题
相似问题