21根火柴游戏(保证电脑胜利)
来源:互联网 发布:网络管理与通信软件 编辑:程序博客网 时间:2024/05/16 06:21
package day141018;
/**
*
* 21根火柴,每次选择1-4根火柴(人先取,最后保证电脑胜利)
* @author XWJ
*/
import java.util.Scanner;
public class Match21 {
public static void main(String[] args) {
Scanner N = new Scanner(System.in);
int total = 21, total2 = 21;
while (total > 1) {
System.out.print("请输入您要抽取的火柴数量:");
int hum = N.nextInt();
int com;
if (1 <= hum || hum <= 4) {
com = 5 - hum;
System.out.printf("电脑抽取的火柴数量为:%d\n", com);
total = total - com - hum;
total2 = total - hum;
System.out.printf("剩余火柴数量为:%d\n", total);
if (total2 == 1) {
System.out.printf("玩家胜利!");
} else if (total == 1) {
System.out.printf("庄家胜利!");
}
}
}
N.close();
}
}
/**
*
* 21根火柴,每次选择1-4根火柴(人先取,最后保证电脑胜利)
* @author XWJ
*/
import java.util.Scanner;
public class Match21 {
public static void main(String[] args) {
Scanner N = new Scanner(System.in);
int total = 21, total2 = 21;
while (total > 1) {
System.out.print("请输入您要抽取的火柴数量:");
int hum = N.nextInt();
int com;
if (1 <= hum || hum <= 4) {
com = 5 - hum;
System.out.printf("电脑抽取的火柴数量为:%d\n", com);
total = total - com - hum;
total2 = total - hum;
System.out.printf("剩余火柴数量为:%d\n", total);
if (total2 == 1) {
System.out.printf("玩家胜利!");
} else if (total == 1) {
System.out.printf("庄家胜利!");
}
}
}
N.close();
}
}
0 0
- 21根火柴游戏(保证电脑胜利)
- 21根火柴游戏
- 21点 21根火柴 常胜将军 简单游戏
- 火柴游戏
- hdu 1907 John(取火柴游戏)
- 21根火柴,每次取1-4根,人和计算机轮流取,保证计算机常胜,C/C++如何实现?
- 四人玩火柴棍游戏
- 趣题2:火柴游戏
- 火柴棍游戏
- 火柴游戏-蓝桥杯
- 蓝桥杯-火柴游戏
- 计蒜客-火柴棍游戏
- 纵横放火柴游戏
- 常胜将军,Java,21根火柴
- 2012蓝桥杯软件大赛决赛(火柴游戏)
- hdu 1907 John(取火柴游戏2)
- 火柴拼接数字的游戏
- 第三届蓝桥杯决赛 火柴游戏
- leetcode :Find Minimum in Rotated Sorted Array
- using thymeleaf之一thymeleaf认识
- Winpcap网络编程八之Winpcap学习教程,发包,发包!
- FZU 2086 餐厅点餐(枚举)
- 反编译unity3d发布apk
- 21根火柴游戏(保证电脑胜利)
- HDU2552 三足鼎立 【数学推理】
- spoj 1470——Another Sequence Problem(Splay Tree)
- 关于ListView中异步加载图片时,图片显示错误的问题
- UVA-11129 - An antiarithmetic permutation (分治)
- Tomcat的安装和部署web应用
- 最详尽的ARM+LINUX移植攻略 linux2.6.30.4内核+yaffs2文件系统+uboot 2009.08
- lis 最长递增序列
- 工作总结