package test1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* 逆序输出控制台输入的字符串
* @author Nihaorz
*
*/
public class ReversePrint {
public static void main(String[] args) {
String a = "", b = "", c = "";
System.out.println("请输入字符串:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
if((b = br.readLine()) != null) {
a = a + b;
}
for(int i = a.length() - 1; i >= 0; i--) {
c = c + a.substring(i, i + 1);
}
System.out.println(c);
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
}
逆序输出控制台输入的字符串
最新推荐文章于 2020-04-16 23:37:13 发布