vpoet

                                   统计单词

                             Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others)




C-sources:
 1 #include <stdio.h>
 2 #include <string.h>
 3 #define N 100
 4 int main()
 5 {
 6     int n,i,p,q,j,k,wordnum;
 7     char ch,temp;
 8 
 9 
10     printf("Please input a n number:\n");
11     scanf("%d%c",&n,&temp);
12 
13 
14     char **str=new char *[n];
15     for(i=0;i<n;i++)
16         str[i]=new char[N];
17 
18 
19     
20     printf("Please input n strings:\n");
21     for(p=0;p<n;p++)
22     {
23         q=0;
24         while((ch=getchar())!=\'\n\')
25         {
26             str[p][q]=ch;
27             q++;
28         }
29     }
30 
31 
32     for(j=0;j<n;j++)
33     {
34         k=0;
35             wordnum=0;
36         while(str[j][k]!=\'\0\')
37         {
38             if(str[j][k]==\' \')
39                 wordnum++;
40             k++;
41         }
42         printf("%d\n",++wordnum);
43     }
44 
45     return 0;
46 }

 


 

分类:

技术点:

相关文章:

  • 2022-01-01
  • 2021-11-07
  • 2021-09-28
  • 2021-12-26
  • 2022-01-18
  • 2021-06-18
  • 2022-01-12
  • 2021-05-25
猜你喜欢
  • 2021-11-01
  • 2021-11-01
  • 2021-11-01
  • 2021-11-01
  • 2021-11-01
  • 2021-05-13
  • 2021-08-27
相关资源
相似解决方案