标签:程序 auto item nts out str pre string key
写出一个程序,接受一个字符串,然后输出该字符串反转后的字符串。例如:
输入N个字符
输出该字符串反转后的字符串
abcd
dcba
import java.util.Scanner;public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); while (in.hasNext()) { String s = in.nextLine(); byte[] b = s.getBytes(); for (int i = b.length-1; i >= 0; i--) { System.out.print((char)b[i]); } } }}写出一个程序,接受一个字符串,然后输出该字符串反转后的字符串。
标签:程序 auto item nts out str pre string key
原文地址:http://www.cnblogs.com/qiaoyanlin/p/6612349.html