崩溃了,这个试了很多都编译错误,能告诉我怎么才能写的对,或者怎样才能运行成功吗,有代码最好,c语言
#include<stdio.h>
#include <string.h>
typedef struct _student
{
char id[20];
char name[20];
double score[4];
double sum;
}student;
int main()
{
student stu[1000],t;
int n=0;
scanf("%s",stu[n].id);
while(strcmp(stu[n].id,"q") != 0)
{
scanf("%s %lf %lf %lf %lf",stu[n].name,&stu[n].score[0],&stu[n].score[1],&stu[n].score[2],&stu[n].score[3]);
stu[n].sum = stu[n].score[0] + stu[n].score[1] + stu[n].score[2] + stu[n].score[3];
n++;
scanf("%s",stu[n].id);
}
for(int i=0;i<n-1;i++)
for(int j=0;j<n-i-1;j++)
{
if(stu[j].sum < stu[j+1].sum)
{
t = stu[j];
stu[j] = stu[j+1];
stu[j+1] = t;
}
}
for(int i=0;i<n;i++)
printf("%s %s %.2lf %.2lf %.2lf %.2lf %.2lf\n",stu[i].id,stu[i].name,stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].score[3],stu[i].sum);
return 0;
}
编译错误不要紧,知道哪错了,把它改对了就行了
你总是参考别人现成的代码,不肯自己动手写,轮到自己写的时候还是写不对