大学生奖学金申请条件判断 - Java 代码实现
import java.util.Scanner;
public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while (t-- > 0) { int n = scanner.nextInt(); int x = scanner.nextInt(); int[] a = new int[n]; int[] b = new int[n]; int sumCredit = 0; int sumScore = 0; boolean fail = false; for (int i = 0; i < n; i++) { a[i] = scanner.nextInt(); sumCredit += a[i]; } for (int i = 0; i < n; i++) { b[i] = scanner.nextInt(); if (b[i] < 60) { fail = true; } sumScore += a[i] * b[i]; } if (fail || (double)sumScore / sumCredit < x) { System.out.println('No'); } else { System.out.println('Yes'); } } } }
原文地址: https://www.cveoy.top/t/topic/oE5e 著作权归作者所有。请勿转载和采集!