《C程序设计语言》练习 1-8,1-9

 1 #include <stdio.h>
 2 /*编写一个统计空格,制表符与换行符个数的程序*/
 3 main()
 4 {
 5   int a,b,c,d;//a表示空格个数,b表示制表符个数,c表示换行符个数
 6   
 7   while((d=getchar())!=EOF)
 8     
 9     {
10       if (d=='\n')
11     {
12       ++c;
13     }
14       if (d=='\t')
15     {
16       ++b;
17     }
18       if (d==' ')
19     {
20       ++a;
21     }
22     }      
23   printf("空格有%d 个,制表符有%d 个,换行符有%d 个\n",a,b,c);
24 }

 

至于练习1-9,http://zhidao.baidu.com/link?url=dy8st012BtPuYYxHcKMcMBIdvpn_7J8DFIK9O5pgG7YtYPKPUGrQD3VrhqLidakVfo0m3pLJZah9VDmKPhMJXa

posted @ 2013-09-11 20:21  叶卢庆  阅读(406)  评论(0编辑  收藏  举报