码迷,mamicode.com
首页 > 其他好文 > 详细

单循环列表

时间:2017-10-23 21:46:38      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:include   next   node   getch   nod   循环   stdio.h   list   tchar   

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 typedef struct Node
 4 {
 5     char a;
 6     struct Node *next;
 7 }Node,*list;
 8 
 9 void p(list L);
10 int main()
11 {
12     list L,s;
13     L=(list)malloc(sizeof(Node));
14     L->next=L;
15     p( L);
16     s=L;
17     while(s->next!=L)
18     {
19         s=s->next;
20         printf("%c ",s->a);        
21     }
22     printf("\n");
23     return 0;
24 }
25 
26 void p(list L)
27 {
28     list r,s;
29     char c;
30     r=L;
31     c=getchar();
32     while(c!=\n)
33     {
34         s=(list)malloc(sizeof(Node));
35         s->a=c;
36         r->next=s;
37         r=s;
38         c=getchar();
39     }
40     r->next=L;
41 }

 

单循环列表

标签:include   next   node   getch   nod   循环   stdio.h   list   tchar   

原文地址:http://www.cnblogs.com/a595452248/p/7718866.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!