一道C语言指结构指针的问题,不知哪错了,有三个错误,请高手帮忙修改一下(超级急)

来源:百度知道 编辑:UC知道 时间:2024/06/21 02:32:11
是结构指针类型,问题:编程生成学生表,只输入四个学生的学号、姓名和前五科成绩,由程序计算出每个人的平均成绩average并填入表中,最后按平均成绩由高到低分顺序输出该表(不要用c++,我使用tc2.0)
#include<stdio.h>
#include<stdlib.h>
#define NUM 4
typedef struct Required_course
{
int english,mathema,physics;
}REQ;
typedef struct Elective
{
int plutonomy,history;
}ELEC;
typedef struct score
{
int number;
char name[15];
REQ req;
ELEC elec;
float average;
}SCORE;
int main()
{
SCORE table[NUM],*p;
void input(SCORE*,int);
SCORE* order(SCORE*,int);
void output(SCORE*,int);
input(table,NUM);
p=order(table,NUM);
output(p,NUM);
return EXIT_SUCCESS;
}
void input(SCORE array[],int n)
{
int i;
SCORE*p=array;
for(i=0;i<n;i++)
{
printf("Number:");
scanf("%1d",&p->number);
printf("Name:");

编译是没有问题,但你代码有错误。
1。
void output (SCORE*p,int n)
{
int i;
printf("\n%s%5s%5s%5s","Number","Engl","Math");
上句少一个参数。格式符有4,而相应变量只有3个。
2。
printf("English Mathema Physic plutonomy history:");
scanf("%d%d%d",&p->req.english,&p->req.mathema,&p->req.physics);
scanf("%d%d",&p->elec.plutonomy,&p->elec.history);
象这里最好是每个输入都有提示,这样才不会输错,
象上面两个输入函数,你输入时容易出错。
留心下你输入时有没出错。

1空格2 空格3回车
4空格 5回车

....我编译了都是通过的。。。。