慕粉flyingidea
2016-05-03 21:39
#include <stdio.h>
int main()
{
int year = 2014; //今年是2014年
//补全一下代码
if(year%4==0)
{
printf("%s\n", "今年是闰年");
}
else
{
printf("%s\n", "今年是平年");
}
return 0;
}
/249/5199/Dm3H/hello.c: In function 'main':
/249/5199/Dm3H/hello.c:8:9: error: stray '\357' in program
printf("%s\n", "今年是闰年");
^
/249/5199/Dm3H/hello.c:8:9: error: stray '\274' in program
/249/5199/Dm3H/hello.c:8:9: error: stray '\233' in program
/249/5199/Dm3H/hello.c:9:5: error: expected ';' before '}' token
}
^
/249/5199/Dm3H/hello.c:12:9: error: stray '\357' in program
printf("%s\n", "今年是平年");
^
/249/5199/Dm3H/hello.c:12:9: error: stray '\274' in program
/249/5199/Dm3H/hello.c:12:9: error: stray '\233' in program
/249/5199/Dm3H/hello.c:13:5: error: expected ';' before '}' token
}
^
= 的意思是赋值,==的意思是等于。
/是除法,%是取余运算。
if(year%4=0&&year/100!=0)改成
if(year%4==0&&year%100!=0)
还有标点符号请 使用英文半角。
你标题上的代码错在了。使用了中文符号。
printf("%s\n", "今年是闰年");分号记得用英文半角来写。
printf("%s\n", "今年是平年");
改完了就好了。
同学,你好!谢谢回答,我修改了代码如下:
#include <stdio.h>
int main()
{
int year = 2014; //今年是2014年
//补全一下代码
if(year%4=0 && year/100!=0)
{
printf("今年是闰年");
}
else
{
printf("今年是平年");
}
return 0;
}
但是运行结果如下:
/249/5199/Dm3H/hello.c: In function 'main':
/249/5199/Dm3H/hello.c:6:14: error: lvalue required as left operand of assignment
if(year%4=0 && year/100!=0)
^
/249/5199/Dm3H/hello.c:8:9: error: stray '\357' in program
printf("今年是闰年");
^
/249/5199/Dm3H/hello.c:8:9: error: stray '\274' in program
/249/5199/Dm3H/hello.c:8:9: error: stray '\233' in program
/249/5199/Dm3H/hello.c:9:5: error: expected ';' before '}' token
}
^
/249/5199/Dm3H/hello.c:12:9: error: stray '\357' in program
printf("今年是平年");
^
/249/5199/Dm3H/hello.c:12:9: error: stray '\274' in program
/249/5199/Dm3H/hello.c:12:9: error: stray '\233' in program
/249/5199/Dm3H/hello.c:13:5: error: expected ';' before '}' token
}
^
闰年的判断是 (year%4==0&&year%100!=0),你没写全
C语言入门
926028 学习 · 20793 问题
相似问题