求指正错误,结构体
#include<stdio.h>struct Student
{
char ID[10];
char name[20];
double score;
};
typedef struct Student st;
void input(struct Student *pa,int n)
{
int i;
for(i=0;i<n;i++)
{
scanf("%d%s%f",&pa[i].ID,pa[i].name,&pa[i].score);
}
}
void max(struct Student*pa,int n)
{
int i,max;
char a[10],b[20];
max=pa[1].score;
a[10]=pa[1].ID;
b[20]=pa[1].name;
for(i=0;i<n;i++)
if(pa[i].score>max)
{
max=pa[i].score;
a[10]=pa[i].ID;
b[20]=pa[i].name;
}
printf("The student who has the highest score is:%s%s%d",a[10],b[20],max);
}
编译没有错误,但运行一直出错
int main()
{
struct Student st[10];
int x,i;
double ave;
do
{
scanf("%d",&x);
}while(x<=0||x>=10);
input(st,x);
for(i=0;i<x;i++)
ave+=st[1+i].score;
printf("The average score=%.2f\n",ave);
max(st,x);
return 0;
}