编译错误、但是在Dev-C++和Visual C++中编译都通过了

评测结果
VijosEx via JudgeDaemon2/13.7.4.0 via libjudge
编译失败(CompileError)

foo.c: In function 'main':
foo.c:44:5: error: 'for' loop initial declarations are only allowed in C99 mode
foo.c:44:5: note: use option -std=c99 or -std=gnu99 to compile your code
foo.c:46:8: warning: format '%s' expects argument of type 'char ', but argument 2 has type 'char ()[25]' [-Wformat]
foo.c:59:5: error: 'for' loop initial declarations are only allowed in C99 mode
CompileError, time = 0 ms, mem = 0 KiB, score = 0

这是源代码:
#include<stdio.h>
#include<string.h>
int N,grade[105],valuation[105],paper[105],allsum,sum[105],maxsum=-1;
char sign,flag;
char name[105][25];
char maxname[105];
char te[105];
void academician(int a)
{
if(grade[a]>80 && paper[a]>0 )
sum[a]=sum[a]+8000;
}

void five(int a)
{
if(grade[a]>85 && valuation[a]>80)
sum[a]=sum[a]+4000;

}

void excellent(int a)
{
if(grade[a]>90)
sum[a]=sum[a]+2000;

}

void west(int a)
{
if(grade[a]>85 && flag=='Y')
sum[a]=sum[a]+1000;

}

void iclass(int a)
{
if(grade[a]>80 &&sign=='Y')
sum[a]=sum[a]+850;

}

int main()
{
memset(sum,0,sizeof(sum));
memset(te,0,sizeof(te));
allsum=0;
scanf("%d",&N);
for(int k=1;k<=N;k++)
{
scanf("%s %d %d %c %c %d",&name[k],&grade[k],&valuation[k],&sign,&flag,&paper[k]);
academician(k);
five(k);
excellent(k);
west(k);
iclass(k);
if(sum[k]>maxsum)
{
maxsum=sum[k];
memset(maxname,0,sizeof(maxname));
strcpy(maxname,name[k]);
}
}
for(int i=1;i<=N;i++)
allsum=allsum+sum[i];
printf("%s\n%d\n",maxname,maxsum);
printf("%d",allsum);
return 0;
}

求指出不当之处,多谢。

2 条评论

  • 1

信息

ID
1001
难度
5
分类
模拟 点击显示
标签
递交数
39307
已通过
12806
通过率
33%
被复制
132
上传者