输出函数的错误在哪里???

#include<iostream>
using namespace std;
#include<string>
//学生结构体定义
struct student
{
	//姓名
	string sName;

	//分数
	int score;

};

//老师结构体定义
struct teacher
{
	//姓名
	string tName;

		//学生数组
	struct student sArray[5];
		 
};
void allocateSpace(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 = 60;
		}
	}


}


void  printfInfor(struct teacher tArray[], int len)
{
	for (int i = 0; i < len; i++)
	{
		cout << "老师的姓名: " << tArray[i].tName[i]<<endl;  
		//int j;
		for (int j = 0; j < 5;j++)
		{
			cout << "学生的姓名:  " << tArray[i].sArray[j].sName <<
				"考试的分数:  " << tArray[i].sArray[j].score << endl;
		}
	} 

}
int main()
{
	//1、创建3名老师的数组
	struct teacher tArray[3];

	//2、通过函数给三名老师赋值,并给老师的学生赋值
	int len = sizeof(tArray) / sizeof(tArray[0]);
	allocateSpace(tArray,len);



	//3、打印所有老师及所带学生的信息
	printfInfor(tArray,len);



	system("pause");
	return 0;
}

#笔试题目#
全部评论
第56行
点赞 回复 分享
发布于 2020-11-09 22:08

相关推荐

点赞 评论 收藏
分享
仁者伍敌:牛子这些人还会点一个自动回复,boss都不带回复的
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
昨天 11:47
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务