这是最笨的办法,老师看了都无语的那种,但是不用数组的情况下,这也是一种解法
输入格式:
第一行有十个整数,表示十位同学的初始分。第二行一个整数n,表示有n道题竞赛。
接下去有n行,每行有一个数字x,x表示本次可以加分的选手序号(每次答对者得10分)。
输出格式:
10个同学最终的得分值,每两位同学之间有一个空格。
输入样例:
10 0 0 0 10 10 0 0 0 10
3
1
10
1
输出样例:
30 0 0 0 10 10 0 0 0 20
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
int e = sc.nextInt();
int f = sc.nextInt();
int g = sc.nextInt();
int h = sc.nextInt();
int i = sc.nextInt();
int j = sc.nextInt();
int k = sc.nextInt();
for (int l = 0; l < k; l++) {
int o = sc.nextInt();
if (o == 1) {
a += 10;
} else if (o == 2) {
b += 10;
} else if (o == 3) {
c += 10;
} else if (o == 4) {
d += 10;
} else if (o == 5) {
e += 10;
} else if (o == 6) {
f += 10;
} else if (o == 7) {
g += 10;
} else if (o == 8) {
h += 10;
} else if (o == 9) {
i += 10;
} else {
j += 10;
}
}
System.out.println(a + " " + b + " " + c + " " + d + " " + e + " " + f + " " + g + " " + h + " " + i + " " + j);
}
}