当前位置:网站首页>1046 punches (15 points)

1046 punches (15 points)

2022-08-11 07:48:00 Stay a bit

题目要求:
在这里插入图片描述
代码:

import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
    
        //輸入
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine();

        int a = 0, b = 0;

        for (int i = 0; i < n; i++){
    

            String line = scanner.nextLine();
            String[] split = line.split(" ");
            int r = Integer.valueOf(split[0]) + Integer.valueOf(split[2]);
            //If A and B are equal, continue
            if (Integer.valueOf(split[1]) == Integer.valueOf(split[3])) continue;
            //喝酒
            if (r == Integer.valueOf(split[1]) ){
    
                b += 1;
            }else if (r == Integer.valueOf(split[3])){
    
                a += 1;
            }
        }

        System.out.println(a + " " + b);
    }
}

结果:
在这里插入图片描述

原网站

版权声明
本文为[Stay a bit]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/223/202208110645413960.html