zoukankan      html  css  js  c++  java
  • 一句话扣单词

     1 #include<stdio.h>
     2 #include<stdlib.h>
     3 #include<ctype.h>
     4 #include<string.h>
     5 const int LEN=1024;
     6 int main(int argc,char* argv[])            //一句话扣单词
     7 {
     8     char arr[LEN];
     9     fgets(arr,sizeof(arr),stdin);
    10     int len=strlen(arr);
    11     bool iswords=0;                        //标记上一个是不是字母或者数字
    12     char temp[LEN];                        //暂存抠出的单词
    13     int tempi=0;
    14     memset(temp,0,sizeof(temp));
    15     for(int i=0 ; i<len ; ++i)
    16     {
    17         if(isalpha(arr[i]) || (arr[i]>='0' && arr[i]<='9')==1)
    18         {
    19             iswords=1;
    20             temp[tempi++]=arr[i];
    21         }
    22         else
    23         {
    24             if(1==iswords)                        //如果上一个是字母或者数字,这个又不是字母或数字,则输出暂存的单词或数字
    25             {
    26                 fputs(temp,stdout);
    27                 fputs(" ",stdout);
    28                 memset(temp,0,sizeof(temp));
    29                 tempi=0;
    30                 iswords=0;
    31             }
    32         }
    33     }
    34     
    35     system("pause");
    36     return 0;
    37 }
  • 相关阅读:
    相机
    播放音乐
    录音
    NSURLConnection下载
    UITableView
    UIPageControl
    UIScrollView
    ajax禁止浏览器缓存
    java替换word2003
    退出登录
  • 原文地址:https://www.cnblogs.com/Evence/p/4471233.html
Copyright © 2011-2022 走看看