我正在尝试反转数组;我输入了数组的长度,而不是所有的值。在那之后,我试着反转它,就像这样:"for construction“中的ai = aal -i- for(int = o;i< al;i++);
我到底做错了什么?完整的代码:
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s1 = new Scanner(System.in);
int al = s1.nextInt();
int a[] = new int[al];
for (int i = 0; i < al; i++) {
a[i] = s1.nextInt();
}
for(int i = 0; i < al; i++) {
a[i] = a[al - i];
}
for(int i = 0; i < al; i++) {
System.out.println(a[i]);
}
}
}
https://stackoverflow.com/questions/52487639
复制相似问题