用C语言写一个月,判断这个月的季节。

# include & ltstdio.h & gt

intmain(){

int month = 0;

Printf("请输入月份:\ n ");

scanf_s("%d ",& amp月);

开关(月){

案例1:

案例2:

案例3:printf(" spring ");打破;

案例4:

案例5:

案例6:printf(" summer ");打破;

案例7:

案例8:

案例9:printf(“秋”);打破;

案例10:

案例11:

case 12:printf(" winter ");打破;

默认值:{

Printf("输入错误");

}

}

return0

}

扩展数据

用C语言输入年和月,得到该年和月的日历。

# include & ltstdio.h & gt

整数年

{

if((y % 4 = = 0)& amp;& amp(y%100!=0)||y%400==0)

return366

其他

return365

}

intmain()

{

inty,m;

inti,j,sum = 0;

intbegin,week

intdays[12]={31,28,31,30,31,30,31,30,31,30,31 };

scanf("%d,%d ",& ampy & amp;m);

for(I = 1900;我& lty;i++)

总和+=年(一);

week =(sum+1)% 7;//指示一年的65438+10月1是星期几。

if(年(y)==366)

days[1]= 29;

Printf("\n%d年%d月日历如下:\n\n ",y,m);

Printf("%d月\n ",m);

printf(" 7123456 \ n ");

printf(" = = = = = = = = = = = = = = = = = = = = = = \ n ");

begin = 1;

for(j = 0;j & lt周;j++)

printf(" ");

while(begin & lt;=天数[m+1])

{

printf("%3d ",begin);

begin++;

周=(周+1)% 7;

if(第%7周==0)

printf(" \ n ");

}

printf(" \ n \ n ");

return0

}