java语言程序设计第十版(Introduce to java 10th) 课后习题 chapter6-32
来源:互联网 发布:淘宝哪家女童卖的好 编辑:程序博客网 时间:2024/05/22 15:41
java语言程序设计第十版(Introduce to java 10th) 课后习题 chapter6-32
自己纯手工,欢迎讨论
package chapter6;public class T32 {public static void main(String[] args) {int win = 0;for(int i=0;i<1000000;i++){win+=rollResult();}System.out.println("You win "+win+" times!");}public static int roll() {int num1 = (int) (Math.random() * 6 + 1);int num2 = (int) (Math.random() * 6 + 1);//System.out.println("You rolled " + num1 + "+" + num2 + "=" + (num1 + num2));return num1 + num2;}public static int rollResult() {int num = roll();if (num == 2 || num == 3 || num == 12) {//System.out.println("You lose.");return 0;} else if (num == 7 || num == 11){//System.out.println("You win!");return 1;}else {//System.out.println("point is " + num);while (true) {int num1 = roll();if (num1 == 7) {//System.out.println("You lose.");return 0;} else if (num1 == num) {//System.out.println("You win!");return 1;}}}}}
0 0
- java语言程序设计第十版(Introduce to java 10th) 课后习题 chapter6-32
- java语言程序设计第十版(Introduce to java 10th) 课后习题 chapter6-27
- java语言程序设计第十版(Introduce to java 10th) 课后习题 chapter6-28
- java语言程序设计第十版(Introduce to java 10th) 课后习题 chapter6-29
- java语言程序设计第十版(Introduce to java 10th) 课后习题 chapter6-30
- java语言程序设计第十版(Introduce to java 10th) 课后习题 chapter6-31
- java语言程序设计第十版(Introduce to java) 课后习题 chapter6-10
- java语言程序设计第十版(Introduce to java 10th) 课后习题 chapter7-32
- java语言程序设计第十版(Introduce to java) 课后习题 chapter6-6
- java语言程序设计第十版(Introduce to java) 课后习题 chapter6-13
- java语言程序设计第十版(Introduce to java) 课后习题 chapter6-14
- java语言程序设计第十版(Introduce to java) 课后习题 chapter6-17
- java语言程序设计第十版(Introduce to java) 课后习题 chapter6-18
- java语言程序设计第十版(Introduce to java) 课后习题 chapter6-22
- java语言程序设计第十版(Introduce to java) 课后习题 chapter6-23
- java语言程序设计第十版(Introduce to java) 课后习题 chapter6-25
- java语言程序设计第十版(Introduce to java) 课后习题 chapter6-26
- java语言程序设计第十版(Introduce to java 10th) 课后习题 chapter7-21
- Java面向对象06-多态,内部类
- Matlab 未找到支持的编译器或 SDK 解决方法归纳
- 域渗透——Skeleton Key
- Ocx 控件添加函数接口,注册控件
- 创建数据库的顺序
- java语言程序设计第十版(Introduce to java 10th) 课后习题 chapter6-32
- firefox 下出现flash上传时提示回话超时,需重新登录问题的解决办法
- 分赌本问题与概率论起步
- 链表实现栈
- 域渗透——Security Support Provider
- [R] Proximal Gradient Descend for Lasso
- Codeforces #305 div2 D. Mike and Feet 递推/单调栈
- netty开发环境配置
- 细节好的人格局一般比较差