#include<stdio.h>
void main()
{
int year,month,days;
printf("请输入年份与月份");
scanf("%d%d",&year,&month);
switch(month)
case 2:
if((year%400==0||(year%4==0&&year%100!=0))
days=29天;
else
days=28天;break;
case 4:case 6:case 9:case 11:
days=30天;break;
default:
days=31天;break;
printf("%d天\n",days);
}
:\c语言\年份月份.cpp(10) : error C2146: syntax error : missing ')' before identifier 'days'
E:\c语言\年份月份.cpp(10) : error C2018: unknown character '0xcc'
E:\c语言\年份月份.cpp(10) : error C2018: unknown character '0xec'
E:\c语言\年份月份.cpp(10) : error C2018: unknown character '0xa3'
E:\c语言\年份月份.cpp(10) : error C2018: unknown character '0xbb'
E:\c语言\年份月份.cpp(11) : error C2143: syntax error : missing ';' before 'else'
E:\c语言\年份月份.cpp(12) : error C2018: unknown character '0xcc'
E:\c语言\年份月份.cpp(12) : error C2018: unknown character '0xec'
E:\c语言\年份月份.cpp(12) : error C2043: illegal break
E:\c语言\年份月份.cpp(13) : error C2046: illegal case
E:\c语言\年份月份.cpp(13) : error C2046: illegal case
E:\c语言\年份月份.cpp(13) : error C2046: illegal case
E:\c语言\年份月份.cpp(13) : error C2046: illegal case
E:\c语言\年份月份.cpp(14) : error C2018: unknown character '0xcc'
E:\c语言\年份月份.cpp(14) : error C2018: unknown character '0xec'
E:\c语言\年份月份.cpp(14) : error C2043: illegal break
E:\c语言\年份月份.cpp(15) : error C2047: illegal default
E:\c语言\年份月份.cpp(16) : error C2018: unknown character '0xcc'
E:\c语言\年份月份.cpp(16) : error C2018: unknown character '0xec'
E:\c语言\年份月份.cpp(16) : error C2043: illegal break
回复 qqq:
非常感谢!但是修改完了还有个问题。
#include<stdio.h>
void main()
{
int year,month,days;
printf("ÇëÊäÈëÄê·ÝÓëÔ·Ý");
scanf("%d%d",&year,&month);
switch(month)
{
case 2:
if((year%400==0)||(year%4==0&&year%100!=0))
days=29;break;
else
days=28;break;
case 4:case 6:case 9:case 11:
days=30;break;
default:
days=31;break;
}
printf("%dÌì\n",days);
}
修改完了,为什么第十二条else还是不对?
error C2181: illegal else without matching if