hdu 1062 Text Reverse
来源:互联网 发布:路由器主人网络关了 编辑:程序博客网 时间:2024/06/13 04:41
题意:输入一串单词反序的句子,输出单词正序的句子;
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int t = sc.nextInt();String temp = sc.nextLine();// 接收回车符while (t-- > 0) {String s = sc.nextLine();String[] strs = s.split(" ");temp = "";for (int i = 0; i < strs.length; i++) {for (int j = strs[i].length() - 1; j >= 0; j--) {temp += strs[i].charAt(j);}if ((i + 1) == strs.length) {continue;}temp += " ";}if (s.endsWith(" ")) {// 接收最后一个空格temp += " ";}System.out.println(temp);}}}
Text Reverse
反向文本
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 20435 Accepted Submission(s): 7797
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,表示测试事件的个数。
T test cases follow.Each test case contains a single line with several words. There will be at most 1000 characters in a line.
紧接着又T行测试事件。每一个测试事件有一行,且由多个单词组成。字符串的长度不超过1000。
Output
For each test case, you should output the text which is processed.
对于每个测试事件,你应该输出处理后的数据。
Sample Input
3olleh !dlrowm'I morf .udhI ekil .mca
Sample Output
hello world!I'm from hdu.I like acm.HintRemember to use getchar() to read '\n' after the interger T, then you may use gets() to read a line and process it.记住用getchar()去接收回车符,然后用 gets() 去读取字符。
Author
Ignatius.L
0 0
- hdu 1062 Text Reverse
- hdu 1062 Text Reverse
- HDU 1062 TEXT REVERSE
- Hdu 1062 - Text Reverse
- hdu 1062 Text Reverse
- HDU 1062 Text Reverse
- hdu 1062 Text Reverse
- HDU 1062 Text Reverse
- HDU 1062 - Text Reverse
- hdu 1062 Text Reverse
- hdu 1062 Text Reverse
- Text Reverse(hdu 1062)
- hdu 1062 Text Reverse
- HDU 1062 Text Reverse
- hdu 1062 text reverse
- HDU 1062 Text Reverse
- HDU 1062 Text Reverse
- hdu 1062 Text Reverse
- spring+hibernate
- 学习jms(一)——基本实例
- leetcode Word Search回溯算法
- ajax表单登陆页面提交后跳转问题
- java并发电子书合集
- hdu 1062 Text Reverse
- JAVA8 最新电子书集合
- PB开发笔记(6)
- thinkphp使用ajax提交后怎么做页面跳转
- hdu 2079 选课时间
- WAS集群:记一次Node Agent不活动问题解决过程
- java-jvm电子书合集
- portal 的基础设施
- R语言常用包分类