打卡11

#include<iostream>
using namespace std;
#include<string>
#include<ctime>
struct student
{
string sname;
int score;
};
struct teacher
{
string tname;
struct student sarray[10];
};

void ssz(struct teacher tarray[],int len)
{
string nameseed="ABCDE";
for(int i=0;i<len;i++)
{
tarray[i].tname="teacher";
tarray[i].tname+=nameseed[i];
for(int j=0;j<5;j++)
{
tarray[i].sarray[j].sname="student";
tarray[i].sarray[j].sname+=nameseed[j];
tarray[i].sarray[j].score=rand()%61+40;
}

}
}
void printft(struct teacher tarray[],int len)
{
for(int i=0;i<len;i++)
{
cout<<tarray[i].tname<<endl;
for(int j=0;j<5;j++)
{
cout<<tarray[i].sarray[j].sname<<tarray[i].sarray[j].score<<endl;
}
}
}

int main()
{
srand((unsigned int)time(NULL));
struct teacher tarray[3];
int len=sizeof(tarray)/sizeof(tarray[1]);
ssz(tarray,len);
printft(tarray,len);

system ("pause");
}

 

posted @ 2023-05-15 00:55  大虚胖子  阅读(11)  评论(0编辑  收藏  举报