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.

    极简,专注,速度,极致
  • 相关阅读:
    背景透明,文字不透明
    判断数组类型
    前端工作流程自动化——Grunt/Gulp 自动化
    tools安装
    总结
    CSS Hack
    getBoundingClientRect()兼容性处理
    Math.random获得随机数
    spring RestTemplate 工程导入
    系统架构演变
  • 原文地址:https://www.cnblogs.com/simplelifestyle/p/3761927.html
Copyright © 2011-2022 走看看