PTA 7-6 评委打分 java语言 班级里要搞智力竞赛 同学们都踊跃参加。进入最后决赛的是10个同学,随着一道道题目的出示,有时是1号选手得分,有时是5号选手得分,每次答对者得10分

这是最笨的办法,老师看了都无语的那种,但是不用数组的情况下,这也是一种解法

输入格式:

第一行有十个整数,表示十位同学的初始分。第二行一个整数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);
    }
}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Black__Emperor

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值