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.

    极简,专注,速度,极致
  • 相关阅读:
    maya粒子生成曲线
    jcFeather 1.5 视频教程系列
    maya 粒子制作海洋岸边convected foam
    maya curveflow修改
    jcFeather 免费限制版本
    欢迎
    用Maya切菜
    easyui 个人使用心得之下拉列表
    SQlServer时间的操作
    数字形式的人民币转换为大写形式
  • 原文地址:https://www.cnblogs.com/simplelifestyle/p/3761927.html
Copyright © 2011-2022 走看看