• TOJ1153. Word Reversal


    1153.   Word Reversal
    Time Limit: 1.0 Seconds   Memory Limit: 65536K
    Total Runs: 5327   Accepted Runs: 2132    Multiple test files



    For each list of words, output a line with each word reversed without changing the order of the words.


    Input

    You will be given a number of test cases. The first line contains a positive integer indicating the number of cases to follow. Each case is given on a line containing a list of words separated by one space, and each word contains only uppercase and lowercase letters.


    Output

    For each test case, print the output on one line.


    Sample Input

    3
    I am happy today
    To be or not to be
    I want to win the practice contest
    


    Sample Output

    I ma yppah yadot
    oT eb ro ton ot eb
    I tnaw ot niw eht ecitcarp tsetnoc
    View Code
     1 #include<iostream>
     2 #include<stack>
     3 using namespace std;
     4 #include<string.h>
     5 #include<stdio.h>
     6 stack<char> s;
     7 char str[1000];
     8 int main()
     9 {
    10     int n,i,len;
    11     cin>>n;
    12     getchar();
    13     while(n--)
    14     {
    15        //cin>>str;
    16       gets(str);
    17        len=strlen(str);
    18        i=0;
    19        while(1)
    20        {
    21           while(str[i]!=' '&&i<len)
    22           {
    23               s.push(str[i]);
    24               i++;
    25           }
    26           while(!s.empty())
    27           {
    28              cout<<s.top();
    29              s.pop();
    30           }
    31           if(i!=len)
    32           {
    33               cout<<' ';
    34               i++;
    35           }
    36           else break;
    37         
    38        }
    39        cout<<endl;
    40           
    41   
    42     }
    43     return 0;
    44 }
    45           
    46           
  • 相关阅读:
    YUV图片旋转
    mac http&git代理配置
    iOS 如何保持线程一直在运转
    iOS 后台录音Tweak实现参考--stackoverflow
    NSTimer的精确度
    svn递归添加目录下面所有文件
    利用instruments工具查看其它app的性能
    iOS符号表手工还原
    Hbase的安装测试工作
    Hadoop集群中pig工具的安装过程记录
  • 原文地址:https://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_2012_08_010.html
Copyright © 2020-2023  润新知