#include <iostream>
#include <string>
#include <ctime>
using namespace std;
//学生结构体
struct Student{
string sName;
int sAge;
int score;
};
//教师结构体
struct Teacher{
string tName;
Student stu[5];
};
//教师-学生分配 3-5
void allocate(Teacher tArr[]){
string rChar = "ABCDE";
for(int i = 0; i < 3; i++){
tArr[i].tName = rChar[i];
cout << "老师teacher_" << tArr[i].tName
<< "的学生:"
<< endl;
for(int j = 0; j < 5; j++){
tArr[i].stu[j].sName = rChar[j];
tArr[i].stu[j].sAge = 22;
tArr[i].stu[j].score = rand() % 61 + 40; //分数范围 40-100
cout << "\t学生student_"
<< tArr[i].stu[j].sName
<< " 年龄:"
<< tArr[i].stu[j].sAge
<< " 成绩:"
<< tArr[i].stu[j].score
<< endl;
}
}
}
int main(){
//随机数种子
srand((unsigned int)time(NULL));
Teacher tArr[3];
allocate(tArr);
return 0;
}