c++学习-链表
静态链表:
#include<iostream> #include<string> using namespace std; struct book{ int num; float price; struct book *next; }; int main() { book x, y, z, *head, *p; x = {1,1.1f}; y = { 2, 2.2f }; z = { 3, 3.3f }; head = &x; x.next = &y; y.next = &z; z.next = NULL; p = head; while (p!=NULL) { cout << p->num<<'\t'<<p->price << endl; p = p->next; } return 0; }