2 #include
3
4 typedef struct student stu_t, *pstu_t;
5
6 struct student
7 {
8 int id;
9 struct stu_t * next;
10 };
11
12 pstu_t create(int id)
13 {
14 pstu_t p = (pstu_t)malloc(sizeof(stu_t));
15 p->id = id;
16 p->next = NULL;
17 return p;
18 }
19
20 pstu_t append(pstu_t h, pstu_t t)
21 {
22
23 pstu_t p;
24 if(h == NULL)
25 return t;
26 for(p = h; p->next != NULL; p = p->next)
27 ;
28 p->next = t;
29 return h;
30 }
31
32 void travel(pstu_t h)
33 {
34 pstu_t p;
35 for(p = h; p->next != h; p = p->next)
36 {
37 printf("id = %d\n", p->id);
38 }
39 printf("id = %d\n", p->id);
40 }
41
42
43 int main(int argc, const char *argv[])
44 {
45 pstu_t head = NULL;
46 pstu_t t, tail, delp;
47 int i , count = 0;
48 // for(i = 0; i < 8; i++)
49 // {
50 // t = create(i+1);
51 // head = append(head, t);
52 // }
53
54 t = create(1);
55 head = t->next = t;
56 tail = t;
57 for(i = 1; i < 10; i++)
58 {
59 t = create(i+1);
60 t->next = tail->next;
61 tail = tail->next = t;
62 }
63 travel(head);
64 t = tail;
65 printf("the key is: ");
66 while(t->next != t)
67 {
68 t = t->next;
69 count++;
70 if(count >= 2)
71 {
72 count = 0;
73 delp = t->next;
74 t->next = delp->next;
75 printf("%d ",delp->id);
76 }
77 }
78 printf("\n");
79 printf("the last kill is: %d\n",t->id);
80 // return 0;
81 }
assignment from incompatible pointer type出现这个警告怎么回事??