题解 | #字符逆序#
字符逆序
http://www.nowcoder.com/practice/cc57022cb4194697ac30bcb566aeb47b
数组 + 交换
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String str = scan.nextLine();
char[] chars = str.toCharArray();
for (int i=0,len = chars.length; i<len/2 ;i++) {
char a = chars[i];
char b = chars[len-1-i];
chars[i] = b;
chars[len-1-i] = a;
}
System.out.println(new String(chars));
}
}