A+B for Input-Output Practice (VI) 的java解法
我的代码如下,但是结果是WrongAnswerimportjava.util.Scanner;publicclassMain{publicstaticvoidmain(S...
我的代码如下,但是结果是Wrong Answer
import java.util.Scanner;
public class Main {
public static void main (String args[]) {
Scanner input = new Scanner(System.in);
int n;
int sum;
int m;
while(true){
n = input.nextInt();
sum = 0;
for (int i = 0; i < n; i++) {
m = input.nextInt();
sum += m;
}
System.out.println(sum);
}
}
} 展开
import java.util.Scanner;
public class Main {
public static void main (String args[]) {
Scanner input = new Scanner(System.in);
int n;
int sum;
int m;
while(true){
n = input.nextInt();
sum = 0;
for (int i = 0; i < n; i++) {
m = input.nextInt();
sum += m;
}
System.out.println(sum);
}
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询