字符逆序
将一个字符串str的内容颠倒过来,并输出。数据范围:
输入描述:
输入一个字符串,可以有空格输出描述:
输出逆序的字符串示例1
输入
I am a student输出
tneduts a ma I示例2
输入
nowcoder输出
redocwonJava 编程
package cn.net.javapub.javaintroduction.example;
/**
* @author: shiyuwang
*/
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
char[] chars = new char[100];
int i = 0;
for (; i < 100; i++) {
int read = System.in.read();
if (read == 10) break;
chars[i] = (char) read;
}
i--;
for (; i >= 0; i--) {
System.out.print(chars[i]);
}
}
}展示效果:

















