问答题
学生的记录由学号和成绩组成,M名学生的数据已在主函数中放入结构体数组stu中,请编写函数proc(),它的功能是:把分数最低的学生数据放在h所指的数组中。注意:分数低的学生可能不止一个。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所编写的若干语句。
试题程序:
#include<stdio.h>
#define M 16
typedef struct
{ char num[10];
int s;
}
STREC;
int proc(STREC*a, STREC*b)
{
}
void main()
{
STREC stu[M]={{"GA005", 82}, {"GA003", 75},
{"GA002", 85}, {"GA004", 78},
{"GA001", 95}, {"GA007", 62},
{"GA008", 60}, {"GA006", 85},
{"GA015", 83}, {"GA013", 94},
{"GA012", 78}, {"GA014", 97},
{"GA011", 60}, {"GA017", 65},
{"GA018", 60}, {"GA016", 74}};
STREC h[M];
int i, n;
n=proc(stu, h);
printf("The %d lowest score: /n", n);
for(i=0; i<n; i++)
printf("%s%4d/n", h[i].num, h[i].s);
//输出最低分学生的学号和成绩
printf("/n");
}