新学C,遇到困难
我编的一个关于年月的问题,可是每次随便输入一对数字输出的都是润年,并且马上WINDOWS会出现出错,找了半天也没找出错误,还请大侠们能帮帮忙
#include <stdio.h>
void main()
{
int year,month,days;
char season,leap;
char spring,summer,autumn,winter; //是不是定义这些字符串的时候出错?
char runnian,pingnian;
printf("input the year(year>0) and month(1<=month<=12):");
scanf("%d%d",&year,&month);
if(year>0)
{if("year/4==0&&y/100!=0||year/400==0")
leap=runnian;
else
leap=pingnian;
}
else
printf("error year input! please reset!");
if(month>=1&&month<=12)
{
if(month>=3&&month<=5)
season=spring;
if(month>=6&&month<=8)
season=summer;
if(month>=9&&month<=11)
season=autumn;
else
season=winter;
}
else
printf("error month input! please reset!"); // 出错
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
days=31;
case 4:
case 6:
case 9:
case 11:
days=30;
case 2:
if(leap=runnian)
days=29;
else
days=28;
}
if(leap==runnian)
printf("该年是润年\n");
else
printf("该年是平年\n");
printf("季度是:%s\n",season);
printf("这个月的天数是:%d",days);
}
[此贴子已经被作者于2006-10-15 16:41:27编辑过]