using namespace std;
#include
#include
#include
#include
Struct Student {
string name;
Int score;
};
Struct the Teacher {
string name;
Student s_arr [5].
};
Void allocatespace (the Teacher t_arr [], int len) {
String t_name="teacher";
String s_name="students";
String nameseed [5]={" A ", "B", "C", "D", "E"};
for (int i=0; i
For (int j=0; j<5; J++) {
T_arr [I] s_arr [j]. Name=s_name + nameseed [j];
Int the random=rand () % 61 + 40;
T_arr [I] s_arr [j]. Score=random;
}
}
}
Void print (the Teacher t_arr [], int len) {
for(int i=0; i
cout <& lt;" Student's name: "& lt;
}
}
Int main () {
Srand ((unsigned int) time (NULL));
The Teacher t_arr [3].
Int len=sizeof (t_arr)/sizeof (t_arr [0]).
Allocatespace (struct the Teacher t_arr [3], len);
Print (struct the Teacher t_arr [3], int len);
return 0;
}
CodePudding user response:
Allocatespace (struct the Teacher t_arr [3], len);//to allocatespace (t_arr, len); Downward similar
Print (struct the Teacher t_arr [3], int len);