静态链表

 1 #include <cstdio>
 2 #include <iostream>
 3 #include <cstring>
 4 #include <string>
 5 #include <cmath>
 6 #include <algorithm>
 7 using namespace std;
 8 const int N = 1000;
 9 
10 struct weapon{
11     int price;
12     int atk;
13     struct weapon * next;
14 };
15 
16 int main()
17 {
18     struct weapon a,b,c, *head;
19     a.price=100;
20     a.atk=100;
21     b.price=200;
22     b.atk=200;
23     c.price=300;
24     c.atk=300;
25     head =&a;
26     a.next=&b;
27     b.next=&c;
28     c.next=NULL;    
29     struct weapon *p;
30     p= head;
31     while(p!=NULL){
32         printf("%d %d\n",p->atk,p->price);
33         p=p->next;
34     }
35     return 0;
36 }
posted @ 2017-08-15 19:08  wydxry  阅读(318)  评论(0编辑  收藏  举报
Live2D