01-用鏈式結構打印學生成績單

用鏈式結構打印學生成績單ios

 

#include <iostream>spa

using namespace std;3d

 

struct StScorecode

{rem

    std::string id;string

    int math;it

    int english;io

    int computer;stream

    struct StScore* next;next

};

 

int main()

{

    StScore first;

    first.id = "C";

    first.math = 80;

    first.english = 85;

    first.computer = 83;

    first.next = nullptr;

 

    StScore second;

    second.id = "A";

    second.math = 75;

    second.english = 91;

    second.computer = 88;

    second.next = nullptr;

    first.next = &second;

    cout<<"id\tmath\tenglish\tcomputer"<<endl;

    StScore* pNode = &first;

    while (pNode != nullptr)

    {

        cout<<pNode->id<<"\t"

            <<pNode->math<<"\t"

            <<pNode->english<<"\t"

            <<pNode->computer

            <<endl;

        pNode = pNode->next;

    }

    return 0;

}

 

結果:

id math english computer

C 80 85 83

A 75 91 88

Program ended with exit code: 0

相關文章
相關標籤/搜索