zoukankan      html  css  js  c++  java
  • 电子科大POJ "统计单词"

                                       统计单词

                                 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:
    ");
    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:
    ");
    21     for(p=0;p<n;p++)
    22     {
    23         q=0;
    24         while((ch=getchar())!='
    ')
    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]!='')
    37         {
    38             if(str[j][k]==' ')
    39                 wordnum++;
    40             k++;
    41         }
    42         printf("%d
    ",++wordnum);
    43     }
    44 
    45     return 0;
    46 }

    作者:vpoet
    点击这里给我发消息
    出处:http://www.cnblogs.com/vpoet/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    Fish
    Brackets
    StoneWall【★★★★★】
    Nesting
    ajax补充FormData
    初始Ajax
    extra过滤
    Django 之缓存
    django中的信号
    Form组件归类
  • 原文地址:https://www.cnblogs.com/vpoet/p/4659768.html
Copyright © 2011-2022 走看看