栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

请问一下我这个C++程序问题出现在哪里

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

请问一下我这个C++程序问题出现在哪里

#include 
using namespace std;

//老师的结构体
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 printinfo(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 << "t学生姓名:" << tArray[i].sArray[j].sname <<
                 "考试的分数: " << tArray[i].sArray[j].score << endl;

        }
    }
}

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

    //通过函数与老师和学生赋值
    int len = sizeof(tArray[3]) / sizeof(tArray[0]);
    allocatespace(tArray, len);

    //打印所有老师及学生的信息
    printinfo(tArray, len);
    system("pause");
    return 0;

}

为什么只能显示第一部分

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/849294.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号