Compile Error
/in/foo.c: In function 'main': /in/foo.c:7:48: error: expected '}' before ']' token int b[12]={31,29,31,30,31,30,31,31,30,31,30,31]; ^ /in/foo.c:7:48: error: expected ',' or ';' before ']' token /in/foo.c:9:22: error: expected expression before '||' token if(n%4==0&&n%100!=0)||n%400==0) ^~ /in/foo.c:9:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation] if(n%4==0&&n%100!=0)||n%400==0) ^~ /in/foo.c:9:32: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if' if(n%4==0&&n%100!=0)||n%400==0) ^ /in/foo.c:9:32: error: expected statement before ')' token /in/foo.c:21:2: error: 'else' without a previous 'if' else ^~~~ /in/foo.c:32:2: error: expected ';' before '}' token } ^
代码
#include <stdio.h>
int main()
{
int n,y,r,s=0,t,i;
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int b[12]={31,29,31,30,31,30,31,31,30,31,30,31];
scanf("%d,%d,%d",&n,&y,&r);
if(n%4==0&&n%100!=0)||n%400==0)
{
if(y==1)
t=r;
if(y==2)
t=31+r;
for(i=0;i<=y-2;i++)
{
s=s+b[i];
}
t=s+r;
}
else
{
if(y==1)
t=r;
if(y==2)
t=31+r;
for(i=0;i<=y-2;i++)
{
s=s+a[i];
}
t=s+r
}
printf("%dth",t);
return 0;
}
信息
- 递交者
- 类型
- 自测
- 题目
- 给出年、月、日,计算该日是该年的第几天
- 语言
- C
- 递交时间
- 2018-06-22 11:04:14
- 评测时间
- 2018-06-22 11:04:14
- 评测机
- 分数
- 0
- 总耗时
- 0ms
- 峰值内存
- 0 Bytes