【c++程序】结构体链表

来源:互联网 发布:用ipad开淘宝店铺教程 编辑:程序博客网 时间:2024/06/14 22:06
#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;}

0 0