zoukankan      html  css  js  c++  java
  • HDU 1062 Text Reverse(水题,字符串处理)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1062

    解题报告:注意一行的末尾可能是空格,还有记得getchar()吃回车符。

     1 #include<cstdio>
     2 #include<string.h>
     3 #include<iostream>
     4 #include<algorithm>
     5 #include<cmath>
     6 #include<deque>
     7 #include<cstdlib>
     8 using namespace std;
     9 
    10 const int maxn = 1000 + 5;
    11 
    12 char temp[maxn],str[maxn];
    13 
    14 int main()
    15 {
    16     int T;
    17     scanf("%d",&T);
    18     getchar();
    19     while(T--)
    20     {
    21         gets(str);
    22         int len = strlen(str),f = 0,flag = 1;
    23         for(int i = 0;i < len;++i)
    24         {
    25             if(str[i] != ' ')
    26             temp[f++] = str[i];
    27             if(str[i] == ' ' || i == len - 1)
    28             {
    29                 temp[f] = NULL;
    30                 reverse(temp,temp+f);
    31                 printf("%s",temp);
    32                 if(i != len - 1 || str[i] == ' ') printf(" ");
    33                 f = 0;
    34             }
    35         }
    36         puts("");
    37     }
    38     return 0;
    39 }
    View Code
  • 相关阅读:
    大学随笔
    TMS320C54X系列DSP上FFT运算的实现(转)
    python第一天学习笔记以及心得
    Struts2学习笔记
    C#实现eval 进行四则运算(有码)
    sql 将字符串转换为表
    XML
    图形用户界面
    java io
    java集合
  • 原文地址:https://www.cnblogs.com/xiaxiaosheng/p/3870550.html
Copyright © 2011-2022 走看看