`

湖南师范大学OJ-10001

    博客分类:
  • ACM
J# 
阅读更多
阅读顺序 
Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB 
Total submit users: 74, Accepted users: 64 
Problem 10001 : No special judgement 
Problem description
  大多数语言是从左向右读的。但是,在一些语言中,阅读顺序是从右向左读的。这给语言交流增加了不少的麻烦。现在,请你编写一个程序,能够将一从左到右书写的文字自动转成从右向左的顺序。


Input
  输入的第一行是一个数字n(n<100),接下来的有n行的文字,由字母、空格、数字以及各种标点组成,每行文字长度不超过200个字符。


Output
  将输入的文字转成从右向左的顺序,一行输入对应一行输出。


Sample Input
3
a man a plan a canal panama
Frankly, I don't think we'll make much
OK?

Sample Output
amanap lanac a nalp a nam a
hcum ekam ll'ew kniht t'nod I ,ylknarF
?KO

Problem Source
  HNU Contest



import java.util.Scanner;

public class Acm10001 {

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int num = Integer.parseInt(cin.nextLine());
		char[][] strs = new char[num][];
		String[] str1 = new String[num];
		StringBuffer[] sb = new StringBuffer[num];
		for(int i=0; i<num ;i++){
			sb[i] = new StringBuffer();
			str1[i] = cin.nextLine();
			strs[i] = str1[i].toCharArray();
			for(int j=strs[i].length-1; j>=0;j--){
				sb[i].append(strs[i][j]);
			}
		}
		for(int i=0; i<num; i++){
			System.out.println(sb[i].toString());
		}
		
	}
	
}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics