我是编程新手,每当我运行此代码时,都会遇到运行时错误[NZEC]。我不知道如何解决该错误
export class Endereco {
cep : string;
rua : string;
complemento: string;
}
答案 0 :(得分:0)
将您的findSum
更改为以下内容。您只需要1个循环
public static int findSum() {
Scanner s = new Scanner(System.in);
System.out.println("Enter total input ");
int n = s.nextInt();
int arr1 [] = new int[n];
int sum = 0;
System.out.println("Enter the " + n + " inputs ");
for (int i = 0; i < n; i++) {
arr[i] = s.nextInt();
if (arr[i] % 2 == 0 || arr[i] % 3 == 0) {
sum = sum + arr[i];
}
}
return sum;
}