zoukankan      html  css  js  c++  java
  • Problem : (1.2.1) Text Reverse

    #include<iostream>
    using namespace std;
    void main()
    {
    	char arr[1000];
    	int a,n;
    	int s,t;
    	cin>>a;
    	getchar();
    	for(int i=0;i<a;i++)
    	{
    		gets(arr);
    		n=strlen(arr);
    		s=0;
    		for(int j=0;j<=n;j++)
    		{
    			if(arr[j]==' '||arr[j]=='')
    				{
    					t=j;
    					for(int l=t-1;l>=s;l--)
    					{
    						cout<<arr[l];
    					}
    					s=t+1;
    					if(s!=n+1)
    						cout<<" ";
    				}
    			
    
    		}
    		cout<<endl;
    	}
    }

    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.
    
    <div style="" border-bottom:="" #b7cbff="" 1px="" dashed;="" border-left:="" padding-bottom:="" 6px;="" padding-left:="" padding-right:="" font-family:="" times"="">
    Hint
    Remember to use getchar() to read ' ' after the interger T, then you may use gets() to read a line and process it.

    极简,专注,速度,极致
  • 相关阅读:
    my first android test
    VVVVVVVVVV
    my first android test
    my first android test
    my first android test
    ini文件
    ZZZZ
    Standard Exception Classes in Python 1.5
    Python Module of the Week Python Module of the Week
    my first android test
  • 原文地址:https://www.cnblogs.com/simplelifestyle/p/3761927.html
Copyright © 2011-2022 走看看