C++ / 構造体をデータ型とした排列を作る

#include <iostream>
#include <string>
using namespace std;

// 構造体を宣言する。
struct qb {
    string Name;
    int Att;
    int Comp;
    int Yds;
    int Td;
    int Int;
    double Rate;
};

int main(){
    // 構造体をデータ型とした排列を作る。
    qb QBs[] = {{"Rodgers, Aaron" , 30, 21, 332, 2, 0, 0},
                {"Wilson, Russell", 31, 21, 225, 2, 0, 0},
                {"Newton, Cam"    , 37, 25, 357, 3, 1, 0}};

    // いくつか読み出してみる。
    for(int i=0; i<3; i++){
        cout << QBs[i].Name << ", " << QBs[i].Yds << endl;
    }


    system("pause");
    return 0;
}

f:id:ti-nspire:20181121164206p:plain