报错:
Main.java:5: error: cannot find symbol
Scanner in = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:5: error: cannot find symbol
Scanner in = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:14: error: cannot find symbol
int a[] = Arrays.copyOf(arr, n);
^
symbol: variable Arrays
location: class Main
Main.java:15: error: cannot find symbol
int b[] = Arrays.copyOfRange(arr, n, m);
^
symbol: variable Arrays
location: class Main
4 errors
我的代码:
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int sum = 0;
if(n>=1&&n<=10) {
int m = 2*n;
int[]arr = new int[m];
for(int i=0;i<m;i++) {
arr[i] = in.nextInt();
}
int a[] = Arrays.copyOf(arr, n);
int b[] = Arrays.copyOfRange(arr, n, m);
for(int k=0;k<n;k++) {
sum = a[k]*b[k]+sum;
}
System.out.println(sum);
}
}
}
我的尝试纠错:
在Scanner前面加上class后报错得寸进尺,让我再加一个class
Arrays前面加了variable也无法得到改善
在PTA上报错,但是在eclipse上是可以正常编译运行的
我想要达到的结果:
输入样例:
3
1 2 3 4 5 6
输出样例:
32