//简单静态链表
#include<iostream>
using namespace std;
struct student
{
int num;
float score;
struct student *next;//指向下一结点的指针
};
int main()
{
student a,b,c,*p,*head;
a.num=31001;a.score=89.5;
b.num=31003;b.score=90;
c.num=31007;c.score=85;
head=&a;//头指针指向a
a.next=&b;
b.next=&c;
c.next=NULL;
p=head;
do
{
cout<<p->num<<" "<<p->score<<endl;
p=p->next;//使p指向下一个结点
}while(p!=NULL);
return 0;
}
C++简单静态链表
最新推荐文章于 2024-09-11 19:54:50 发布