首页 > 编程语言 > 详细

c++程序—结构体数组

时间:2020-03-11 02:03:28      阅读:70      评论:0      收藏:0      [点我收藏+]
#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;

}

 

c++程序—结构体数组

原文:https://www.cnblogs.com/hackerteen/p/12459665.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!