|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include<iostream>
- using namespace std;
- struct student
- {
- string name;
- double score;
- };
- struct teacher
- {
- string name;
- struct student s[5];
- };
- void messageTeacher(struct teacher t[],int n)
- {
- for(int i=0;i<n;i++)
- {
- cout<<"第"<<i+1<<"个老师名字:";
- cin>>t[i].name;
- for(int j=1;j<5;j++)
- {
- cout<<"第"<<j<<"个学生名字:";
- cin>>t[i].s[j].name;
- cout<<"第"<<j<<"个学生分数:";
- cin>>t[i].s[j].score;
- }
- }
- }
- void print(struct teacher t[],int n)
- {
- for(int i=0;i<n;i++)
- {
- cout<<"老师姓名"<<t[i].name;
- for(int j=0;j<5;j++)
- {
- cout<<"学生姓名"<<t[i].s[j].name<<"学生分数"<<t[i].s[j].score<<endl;
- }
- }
- }
- int main()
- {
- struct teacher T[3];
- int len=3;
- messageTeacher(T,len);
- print(T,len);
- return 0;
- }
- 第一个问题:messageTeacher函数中我只输入了信息,并没有让其打印,可是不知道为什么输入之后一案回车就自动输出?软件是Clion
- 第二个问题:不知道哪里出错,第一次循环信息输入完成按下回车就乱码了
- 求指导!!!
复制代码 |
|