HDOJ/HDU 1321 Reverse Text(倒序输出~)
Problem Description
In most languages, text is written from left to right. However, there are other languages where text is read and written from right to left. As a first step towards a program that automatically translates from a left-to-right language into a right-to-left language and back, you are to write a program that changes the direction of a given text.
Input
The input contains several test cases. The first line contains an integer specifying the number of test cases. Each test case consists of a single line of text which contains at most 70 characters. However, the newline character at the end of each line is not considered to be part of the line.
Output
For each test case, print a line containing the characters of the input line in reverse order.
Sample Input
3
Frankly, I don’t think we’ll make much
money out of this scheme.
madam I’m adam
Sample Output
hcum ekam ll’ew kniht t’nod I ,ylknarF
.emehcs siht fo tuo yenom
mada m’I madam
就是输入一行字符串,然后倒序输出就可以了~
import java.util.Scanner;
/**
* @author 陈浩翔
* 2016-5-25
*/
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t =sc.nextInt();
sc.nextLine();//读取数字后的回车
while(t-->0){
String str =sc.nextLine();
for(int i=str.length()-1;i>=0;i--){
System.out.print(str.charAt(i));
}
System.out.println();
}
}
}
HDOJ/HDU 1321 Reverse Text(倒序输出~)的更多相关文章
- HDOJ/HDU 1062 Text Reverse(字符串翻转~)
Problem Description Ignatius likes to write words in reverse way. Given a single line of text which ...
- C#字符串的倒序输出
介绍 在本文中,我将演示如何将字符串的单词倒序输出.在这里我不是要将“John” 这样的字符串倒序为成“nhoJ”,.这是不一样的,因为它完全倒序了整个字符串.而以下代码将教你如何将“你 好 我是 缇 ...
- Java基础知识强化08:将字符串倒序输出(包括空格)的几种方法
1.最容易想到的估计就是利用String类的toCharArray(),再倒序输出数组的方法了: package himi.hebao05; public class TestDemo02 { pub ...
- Python中将一个对象倒序输出的4种方法
Python中将一个对象倒序输出的4种方法就用列表来举例说明吧: >>> lst = [1,2,3,4,5,6] #创建测试列表 #方法1: >>> lst.rev ...
- java字符串实现正序和倒序输出
##一共4种方式 /* * string倒序输出 * 利用String类的toCharArray(),再倒序输出数组的方法 * 2018-5-18 1 ...
- Java实现字符串倒序输出的几种方法
1. 最容易想到的估计就是利用String类的toCharArray(),再倒序输出数组的方法了. import javax.swing.JOptionPane; public class Rever ...
- TJU Problem 1644 Reverse Text
注意: int N; cin >> N; cin.ignore(); 同于 int N; scanf("%d\n",&N); 另:关于 cin 与 scanf: ...
- Java取出字符串中的大写字母,并倒序输出
package catic.test; /** * @ClassName: TestXBQ * @Description: TODO 输出字符串中的大写字母,并倒序输出 * @author xbq * ...
- HDOJ(HDU).2844 Coins (DP 多重背包+二进制优化)
HDOJ(HDU).2844 Coins (DP 多重背包+二进制优化) 题意分析 先把每种硬币按照二进制拆分好,然后做01背包即可.需要注意的是本题只需要求解可以凑出几种金钱的价格,而不需要输出种数 ...
随机推荐
- “jni.h”: No such file or directory
VS2010解决方案: 进入 “包含目录“ 方式: 右键项目属性页-> 配置属性->VC++目录->包含目录 在”包含目录“中编辑 添加以下路径: C:\Program Files\ ...
- OC调用Swift 整理步骤!总结别人的!方便自己查找!
1. 2. 上面的修改了一个配置项,有一个Product Module Name在后面会使用. 在工程里面点击File/New/File…,选择iOS/Source/Cocoa Touch Class ...
- 【AngularJS】——0.分析
[引导分析]1.什么是AngularJS? 2.为什么要使用它? 3.应用场合? 4.基本思想? 5.四大核心特征? 6.优缺点是什么? 1.定义:AngularJS是一个用于设计动态web应用的前端 ...
- Win32中GDI+应用(二)--初始化与清理
GDI+提供了GdiplusStartup和 GdiplusShutdown 函数来进行初始化和完成清理工作.你必须在调用其他的GDI+函数之前,调用GdiplusStartup函数,在完成GDI+工 ...
- XML&DTD&XML Schema学习
XML(eXtensible Markup Language)可扩展的标记语言.xml在web service编程中尤为重要.在网络传输中可以作为传输数据的载体.xml作为元语言,它可以用来标记数据. ...
- jquery fancybox ie6无法显示关闭按钮
解决办法: 打开jquery.fancybox-1.3.4.css 注释掉这行就行了: .fancybox-ie6 #fancybox-close { background: transparent; ...
- C#连接、访问MySQL数据库
一.准备工具 visual stuido(本示例使用visual studio 2010) MySql.Data.dll mysql_installer_community_V5.6.21.1_set ...
- HMM模型
通过前几时断续的学习,发现自己对HMM模型的了解还只停留在皮毛,导致在学习CRF模型并将其与最大熵模型.HMM.MEMM做比较时感觉很吃力,所以又花了两天时间使劲看了遍HMM,发现了解得确实深刻了很多 ...
- gcc/g++命令认识
gcc & g++是gnu中最主要和最流行的c & c++编译器 . g++用来针对c++的处理命令,以.cpp为后缀,对于c语言后缀名一般为.c.这时候命令换做gcc即可. 下面以T ...
- 监视/etc/passwd文件是否正常
帮助监视/etc/passwd文件是否正常(P90 练习6.7) 1)找出有UID0的所有项 2)找出有重复UID的所有项 3)找出有重复登录名的所有项 4)找出没有口令的所有项 5)找出没有作废日期 ...