#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; }
时间: 2024-10-09 08:44:44