Text Reverse

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

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.

Hint

Remember to use getchar() to read '\n' after the interger T, then you may use gets() to read a line and process it.

import java.util.Scanner;
public class Main {
static String reverseStr(String str){
StringBuffer buf=new StringBuffer();
buf.append(str);
return buf.reverse().toString(); }
public static void main(String [] args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
sc.nextLine();
while(t-->0){
String str1=sc.nextLine();
String str[]=str1.split(" ");
for(int i=0;i<str.length;i++){
System.out.print(reverseStr(str[i]));
if(i<str.length-1)
System.out.print(" ");
}
if(str1.endsWith(" "))System.out.print(" "); ////尤其注意这里,表示最后一个字符后可能有空格
System.out.println(); }
sc.close();
} }

1.2.2 Text_Reverse的更多相关文章

随机推荐

  1. React native 的DatePickerIOS组件

    1.首先如代码所示  引入DatePickerIOS组件 设置他的时间是当前时间 export default class AlertDemo extends Component { render() ...

  2. pandas (loc、iloc、ix)的区别

    loc:通过行标签索引数据 iloc:通过行号索引行数据 ix:通过行标签或行号索引数据(基于loc和iloc的混合) 使用loc.iloc.ix索引第一行数据: loc: iloc: ix:

  3. STL_容器共通能力

    1. 来自教程: ◆ 所有容器提供的都是值(value)语意,而非引用(reference)语意.容器执行插入元素的操作时,内部实施拷贝动作.所以STL容器内存储的元素必须能够被拷贝(必须提供拷贝构造 ...

  4. R-FCN论文理解

    一.R-FCN初探 1. R-FCN贡献 提出Position-sensitive score maps来解决目标检测的位置敏感性问题: 区域为基础的,全卷积网络的二阶段目标检测框架: 比Faster ...

  5. iOS Socket编程-C语言版(TCP)

    . TCP Socket编程 TCP是面向连接的,安全可靠的传输层协议.TCP的程序基本框架设计图: TCP的程序基本框架设计图.jpg 注意:Socket通信一定有要服务端和客户端. 1.1 TCP ...

  6. Codeforces 898F - Restoring the Expression(字符串hash)

    898F - Restoring the Expression 思路:字符串hash,base是10,事实证明对2e64取模会T(也许ull很费时),对1e9+7取模. 代码: #include< ...

  7. 手动添加 launcher 到 Ubuntu Unity

    本来,启动程序之后,在左边的launcher bar点右键,[Lock to Launcher]就可以的. 但是,有时候因为某种原因,需要手工添加. 这时候,就要参考下面的文章了 http://ask ...

  8. 一个简单可参考的API网关架构设计

    网关一词较早出现在网络设备里面,比如两个相互独立的局域网段之间通过路由器或者桥接设备进行通信, 这中间的路由或者桥接设备我们称之为网关. 相应的 API 网关将各系统对外暴露的服务聚合起来,所有要调用 ...

  9. Linux : 密码正确不能正常登陆,日志提示Could not get shadow information for user

    今天,再玩Centos7的时候,尝试修改了下ssh的端口.因为默认开启了SELinux,如果没有修改这个文件配置就修改端口sshd服务就不能正常启动了. 但是,当我修改会22端口的时候还是不能正常登陆 ...

  10. Mycat配置入门

    配置: --bin 启动目录 --conf 配置文件存放配置文件: --server.xml:是Mycat服务器参数调整和用户授权的配置文件. --schema.xml:是逻辑库定义和表以及分片定义的 ...