解题思路: 循环判断输出
注意事项: 注意当达到21分时,需要比对方对>=2分才会胜利
参考代码:
import java.util.Scanner; public class Main { public static void main(String []args) { Scanner in = new Scanner(System.in); int score[]=new int[2]; while(in.hasNext()) { int a=in.nextInt(); if(a==0) score[0]++; else score[1]++; if(score[0]>=21&&score[0]-score[1]>=2) { System.out.println(0);break; } if(score[1]>=21&&score[1]-score[0]>=2) { System.out.println(1);break; } } in.close(); } }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:901 |
【计算两点间的距离】 (C语言代码)浏览:883 |
十->二进制转换 (C语言代码)浏览:1291 |
蛇行矩阵 (C语言代码)浏览:752 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:1195 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)from DQM浏览:666 |
printf基础练习2 (C语言代码)浏览:618 |
a+b浏览:433 |
模拟计算器 (C++代码)浏览:806 |
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:509 |