现在给出n个同学的姓名,语文成绩,数学成绩,要求你按输入顺序的倒序输出每个人的姓名,语文成绩,数学成绩,总分。1<n<100
输入/输出例子1
输入:
4
gaoxiang 78 96
wangxi 70 98
liujia 90 87
zhangjin 78 90
输出:
zhangjin 78 90 168
liujia 90 87 177
wangxi 70 98 168
gaoxiang 78 96 174
样例解释
无
#include<bits/stdc++.h>
using namespace std;
int n;
struct stu{
string name;
int yuwen;
int shuxue;
int zf;
}a[105];
int main(){
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i].name >> a[i].yuwen >> a[i].shuxue;
a[i].zf = a[i].yuwen + a[i].shuxue;
}
for(int i = n; i >= 1; i--) cout << a[i].name <<" "<< a[i].yuwen <<" " << a[i].shuxue <<" "<< a[i].zf << endl;
return 0;
}