#include<iostream>
using namespace std;
struct book//公有的
{
int num;
float price;
struct book*next;
};
int main()
{
book x,y,z,*head,*p;
x.num=10000;
x.price=14.5f;
y.num=20000;
y.price=23.4f;//默认为双精度
z.num=30000;
z.price=45.6f;
head=&x;
x.next=&y;
y.next=&z;
z.next=NULL;//伪节点
p=head;//指向头节点
while(p!=NULL)
{
cout<<p->num<<endl<<p->price<<endl;
p=p->next;
}
return 0;
}
【c++程序】结构体链表
最新推荐文章于 2024-05-01 16:20:32 发布