习题113(垂直方向直方图):编写一个程序打印输入中单词长度的垂直方向的直方图。

 1 /*
 2 int main()
 3 {
 4      int c,nl;
 5      nl=0;
 6      while((c=getchar())!=EOF)
 7      {
 8            if(c=='\n')
 9              ++nl;
10          }
11          printf("%d\n",nl);
12      
13 }*/
14 
15 
16 #include<stdio.h>
17 #include<stdlib.h>
18 
19 void main()
20 {
21      int c,nl,space_n;
22      nl=space_n=0;
23      while((c=getchar())!=EOF)
24      {
25           if(c=='\n')
26           ++nl;
27        else if(c==' ')
28           ++space_n;
29          }
30          printf("%d,%d",nl,space_n);
31 }

 

原文地址:https://www.cnblogs.com/cpoint/p/2868540.html