c++程序—结构体数组
#include<iostream> using namespace std; #include<string> //结构体数组 struct student { string name; int age; float score; }; int main() { struct student studentArr[3] = { {"张三",18,97.5}, {"李四",19,60}, {"王五",17,78}, }; studentArr[1].score = 85.5; for (int i = 0; i < 3; i++) { cout << "姓名: " << studentArr[i].name <<" " << "年龄: " << studentArr[i].age <<" " << "分数: " << studentArr[i].score<<" " << endl; } system("pause"); return 0; }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步