链表思想

 1 #include <stdio.h>
 2  
 3 /* count lines in input */
 4 int
 5 main()
 6 {
 7         int c, pc; /* c = character, pc = previous character */
 8  
 9         /* set pc to a value that wouldn't match any character, in case
10         this program is ever modified to get rid of multiples of other
11         characters */
12  
13         pc = EOF;
14  
15         while ((c = getchar()) != EOF) {
16                 if (c == ' ')
17                         if (pc != ' ')   /* or if (pc != c) */ 
18                                 putchar(c);
19  
20                 /* We haven't met 'else' yet, so we have to be a little clumsy */
21                 if (c != ' ')
22                         putchar(c);
23                 pc = c;
24         }
25  
26         return 0;
27 }

PS:   PC 模拟 C前一个节点!

posted @ 2013-05-02 15:31  Levi.duan  阅读(220)  评论(0编辑  收藏  举报