|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
想打一个输入那年哪月那天,输出是该年的第几天的程序,区分闰年,但总是说case illegal,求助啦蟹蟹。
#include <stdio.h>
void main()
{
int a, b, c, d, panduan;
printf("please input a day: xxx year, xxx month, xxxday\n");
scanf("%d %d %d"&a, &b, &c);
if(a%400 == 0)
{
panduan = 1;
}
else
{
panduan = 0;
}
if(panduan = 1)
{
switch(b)
case 1:printf("%d",c);break;
case 2:printf("%d",c+31);break;
case 3:printf("%d",c+60);break;
case 4:
case 5:
case 6:
case 7: d = (b/2 - 1)*30 +29+(b/2 + 1)*31;
printf("%d", d);
break;
case 8:
case 9:
case 10:
case 11:
case 12: d = 60+29+124+((b-7)/2+1)*31+((b-7)/2)*30;
printf("%d", d);
break;
default:printf("error");
}
else
{
switch(b)
case 1:printf("%d",c);break;
case 2:printf("%d",c+31);break;
case 3:printf("%d",c+59);break;
case 4:
case 5:
case 6:
case 7: d = (b/2 - 1)*30 +28+(b/2 + 1)*31;
printf("%d", d);
break;
case 8:
case 9:
case 10:
case 11:
case 12: d = 60+28+124+((b-7)/2+1)*31+((b-7)/2)*30;
printf("%d", d);
break;
default:printf("error");
}
}
1. scanf("%d %d %d"&a, &b, &c); 少打了个逗号 &a前面
2. if(panduan = 1) 要改为 if(panduan == 1)
3. switch 要打大括号 switch(b)
{
case 1:
}
|
|