参考代码:
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int na = scanner.nextInt(); int nb = scanner.nextInt(); int []a = new int[na]; for(int i = 0; i < na; i++) a[i] = scanner.nextInt(); int []b = new int[nb]; for(int i = 0; i < nb; i++) b[i] = scanner.nextInt(); int awin = 0; int bwin = 0; for(int i = 0; i < n; i++) { if(a[i % na] == b[i % nb]) continue; if(a[i % na] == 0 && b[i % nb] == 2 || a[i % na] == 2 && b[i % nb] == 5 || a[i % na] == 5 && b[i % nb] == 0) awin++; else bwin++; } if(awin > bwin) System.out.println("A"); else if(bwin > awin) System.out.println("B"); else System.out.println("draw"); } }
0.0分
5 人评分
ASCII帮了大忙浏览:797 |
数组输出 (C语言代码)--此题的题目描述有问题浏览:1844 |
C语言训练-求1+2!+3!+...+N!的和 (C语言代码)万恶的long long浏览:906 |
【排队买票】 (C语言代码)浏览:944 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:1261 |
众数问题 (C语言代码)浏览:911 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:592 |
C语言程序设计教程(第三版)课后习题11.8 (C语言代码)浏览:756 |
IP判断 (C语言代码)浏览:592 |
前10名 (C语言代码)浏览:773 |