最简单的链表

来源:互联网 发布:如何申请手机淘宝账号 编辑:程序博客网 时间:2024/04/28 08:06
#include<iostream>
#include<iomanip>
using namespace std;
struct Student
{
int num;
int score;
Student *q;
};
int main()
{
Student a, b, c,*p=&a;
a.num = 1; b.num = 2; c.num = 3;
a.score = 30; b.score = 60; c.score = 90;
a.q  = &b;
b.q  = &c;
c.q  = NULL;
do
{
cout << p->num << " " << p->score << endl;
p = p->q;
} while (p != NULL);
cin >> a.num;
return 0;
}
0 0
原创粉丝点击