HDu,acm2061 为什么用结构体就WA???
#include<stdio.h>#include<string.h>
struct students
{
char name[31];
int crdeits;
int score;
};
students a[100];
int main()
{
int t,n,f;
double sum1,sum2,gpa;
scanf("%d",&t);
while(t--)
{
sum1=0;sum2=0,f=0,gpa=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%s%d%d",&a[i].name,&a[i].crdeits,&a[i].score);
sum1+=(a[i].crdeits*a[i].score);
sum2+=a[i].crdeits;
if(a[i].score<60)
{
f=1;
}
}
gpa=sum1/sum2;
if(f) printf("Sorry!\n");
else
{
printf("%.2lf\n",gpa);
}
if(t!=0)
printf("\n");
}
return 0;
}