我写的这段代码循环出错了,求解释!!
#include<stdio.h>#include<string.h>
struct stu
{
char name[20];
int end;
int classmate;
char cadre;
char east;
int rest;
}s[100];
int main()
{
struct stu s[100];
int x,i,t,sum=0,max=0,esum=0;
scanf("%d",&x);
for(i=0;i<x;i++)
{
scanf("%s%d%d",&s->name,&s->end,&s->classmate);
getchar("%c",&s->cadre);
getchar("%c",&s->east);
scanf("%d",&s->rest);
}
for(i=0;i<x;i++)
{
if(s->end>80&&s->rest>0)
sum=sum+8000;
if(s->end>85&&s->classmate>80)
sum=sum+4000;
if(s->end>90)
sum=sum+2000;
if(s->end>85&&s->east=='Y')
sum=sum+1000;
if(s->classmate>80&&s->cadre=='Y')
sum=sum+850;
esum+=sum;
if(sum>max)
{
max=sum;
t=i;
}
}
printf("%s\n",s[t].name);
printf("%d\n%d\n",sum,esum);
return 0;
}
这弄死我了,死活好不了。我循环输入的时候就是差一个输入。我却看不出问题,f7(vc)时没有报错呀!!!!