zoukankan      html  css  js  c++  java
  • Text Reverse

    Problem Description
    Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them.
     
    Input
    The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains a single line with several words. There will be at most 1000 characters in a line.
     
    Output
    For each test case, you should output the text which is processed.
     
    Sample Input
    3
    olleh !dlrow
    m'I morf .udh
    I ekil .mca
     
    Sample Output
    hello world!
    I'm from hdu.
    I like acm.
    
    

     输入输出的练习

    #include<string>
    #include<stdio.h>
    #include<iostream>
    using namespace std;
    
    int main()
    {
        string s;
        int l,i,j,k,n;
        cin >> n;
        getchar();
        while(n--)
        {
            getline(cin,s);
            l = s.length();
            for(k=0,j=-1;k<=l;k++)
            {
                if(s[k]==' '||k==l)
                {
                    for(i=k-1;i>j;i--)
                    {
                        cout << s[i];
                    }
                    if(k!=l)
                        cout <<' ';
                    else
                        cout <<endl;
                    j=k;
                }
            }
        }
        return 0;
    }
  • 相关阅读:
    转战Python
    spark
    idea的配置
    19年春第十六周学习
    19年春第十五周学习
    个人作业-最长英语链
    rpm dpkg 用法比较
    foxmail 无法下载同步邮件 error:00000001:lib(0):func(0):reason(1)
    date命令详解
    用cron服务自动运行脚本
  • 原文地址:https://www.cnblogs.com/gaosshun/p/3541648.html
Copyright © 2011-2022 走看看