第十章-1-结构体练习
/* * @Issue: 利用结构体类型编写程序,实现输入一个学生的数学期中和期末成绩,计算并输出平均值 * @Author: 一届书生 * @LastEditTime : 2020-02-08 12:19:13 */ #include<iostream> using namespace std; struct study{ int mid,end,average; }math; int main(){ while(cin>>math.mid>>math.end){ math.average=math.mid+math.end>>1; cout<<math.average<<endl; } return 0; } /* * @Issue: 利用sort编写程序,实现输入3个学生的学号、数学期中和期末成绩,然后计算平均成绩 * 并输出成绩表 * @Author: 一届书生 * @LastEditTime : 2020-02-08 12:41:14 */ #include<iostream> #include<algorithm> #include<string> using namespace std; struct s { string id; int mid,end,average; }student[3]; bool cmp(s a,s b){ return a