想复杂了,直接通过循环并调用i就行了
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
String s = sc.next();
char c[] = s.toCharArray();
for (int i = 0; i < c.length / 2; i++) {
/**交换位置*/
char t = c[i];
c[i] = c[c.length - 1 - i];
c[c.length - 1 - i] = t;
/**输出交换后序列*/
for (int j = 0; j < c.length; j++)
System.out.print(c[j]);
System.out.println();
}
System.out.println();
for (int j = 0; j < c.length; j++)
System.out.print(c[j]);
}
}