#include "stdio.h"
#define NC 100
struct studentRed { //定义学生记录,即对应表格的一行
char studName[20]; //姓名对应第一列的Student Name
char studID[20]; //学号对应第二列的Student ID 用20个字符编码,可用字母做学号
float compProgram; // score for Computer programming 用浮点数可输入小数分数
float physEducat; //score for Computer programming
float commResech; //score for Communication and Research
float averageScore; //average score
}*p,students[NC]={
{"John","zy001",84,86,78,0},
{"Xiaoming","zy002",77,82,90,0},
{"Xiaohua","zy003",79,82,85,0},
{"Jianguo","zy004",84,86,78,0},
{"Xiaodong","zy005",60,55,40,0},
};
void insertAvgScore(struct studentRed *stu,int length){
for (int i = 0; i <length ;++i) {
stu[i].averageScore=(stu[i].compProgram+stu[i].physEducat+stu[i].commResech)/3;
}
}
void printStudentInfo(struct studentRed *stu,int length){
printf("Name\t\tID\t\tComputer\tPhysical\tCommunication\tAverages\n");
for(int i=0;i<length;i++){
printf("%-12s%s",stu[i].studName,stu[i].studID,stu[i].compProgram,stu[i].physEducat,stu[i].commResech,stu[i].averageScore);
}
}
int main(){
insertAvgScore(students,5);
printStudentInfo(students,5);
return 0;
}