用构造体数组的办法改写例9-1
【例9-1】按表9-1的模式从键盘顺次输出每个学生的学号、姓名、出生年月、3门课的问题,计算并打印出每个学生的均匀问题。
输出
第一行,整数n,示意一共有n个学生。
从第二行开始共n行,每行蕴含学号,姓名,出生年月,数学,英语,C语言,空格隔开,姓名不含空格,出生年月离开输出。
输入
共n行,每行蕴含学号,姓名,出世年/月,数学,英语,C语言,均匀问题。
输入浮点数应用%.0f,出生年月用/离开。
样例输出 Copy
2
901 hulei 1990 8 67 78 89
902 fangang 1991 7 85 69 76
样例输入 Copy
901 hulei 1990/8 67 78 89 78
902 fangang 1991/7 85 69 76 77

代码示例(本人写的,只能过平台,不完满)

//#include<iostream>//#include<string>//#include<string.h>//#include <algorithm>//using namespace std;////struct student{//    int um;//    char name[20];//    int year,mon;//    double math,eng,c;//    double aver;//}stu[20];////int main(){//    int n = 0;//    while(cin >> n){//        for(int i = 0; i < n; i++){//            scanf("%d %s %d %d %lf %lf %lf",&stu[i].um,&stu[i].name,&stu[i].year,&stu[i].mon,&stu[i].math,&stu[i].eng,&stu[i].c);//            stu[i].aver = (stu[i].math + stu[i].eng + stu[i].c) / 3;//        }//        for(int i = 0; i < n; i++){//            printf("%d %s %d",stu[i].um,stu[i].name,stu[i].year);//            cout << "/";//            printf("%d %g %g %g ",stu[i].mon,stu[i].math,stu[i].eng,stu[i].c);//            printf("%.0f\n",stu[i].aver);//        }//    }//    return 0;//}