#include<iostream>
using namespace std;
//写一个函数print,打印一个学生的成绩数组
struct Student
{
string name;
int num;
double score[3];
};
void print(Student& stu)
{
cout << stu.num <<" " << stu.name << " ";
for (int j = 0; j < 3; j++)
cout << stu.score[j] << " ";
cout << endl;
}
int main()
{
Student stud[3];
for (int i = 0; i < 3; i++)
{
cout << "请输入第" << i + 1 << "个学生的信息:" << endl;
cin >> stud[i].num >> stud[i].name;
for (int j = 0; j < 3; j++)
cin >> stud[i].score[j];
}
cout << "学生的信息分别为:" << endl;
for (int i = 0; i < 3; i++)
print(stud[i]);
return 0;
}
谭浩强c++第三版7-3
最新推荐文章于 2021-09-04 16:52:31 发布