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;
    }
  • 相关阅读:
    textarea输入限制
    MyBatis 下使用SQLite
    天气预报
    导出Excel、csv
    WDK 常用的几个函数
    Windows 内核 hello world
    内核模式下的文件操作
    Windows 内核编程初涉
    Windows 内地管理
    Windows 内核 同步处理
  • 原文地址:https://www.cnblogs.com/gaosshun/p/3541648.html
Copyright © 2011-2022 走看看