Java 循环运算试题1
来源:互联网 发布:suse linux 安装gcc 编辑:程序博客网 时间:2024/05/29 15:44
package src;// 百鸡百钱问题:public class Java2 {public static void main(String[] args) {for(int x = 0; x <= 20; x++){for(int y = 0; y <= 33; y++){int r = 100 -x -y;if (5 * x + 3 * y + r / 3 == 100 && r % 3 == 0){System.out.printf("公鸡%d\n母鸡%d\n小鸡%d\n\n" , x, y, r );}}}}}
package src;import java.util.Scanner;public class Test3 {public static void main(String[] args) {Scanner sc = new Scanner(System.in);System.out.print("请输入你想下注的数:");if(sc.hasNext()){int n = sc.nextInt();if (n > 0){for(int j = 1; j <= n; j++){for(int i = 1; i <= 7; i++);{System.out.print((int) (Math.random() * 10) + " ");}System.out.println();}}}sc.close();}}
}package src;import java.util.Scanner;/** * * Craps赌博游戏 * @author 张小龙 * */public class Test5 {public static int roll(){return (int) (Math.random() * 6 + 1);}public static void main(String[] args) { Scanner sc = new Scanner(System.in);int money = 10000;int firstpoint, currentpoint;for( ; money > 0 ;){firstpoint = currentpoint = roll() + roll();System.out.println("现在有 " + money + "" );boolean goon = false;System.out.println("请下注: "); int n = sc.nextInt(); System.out.println("玩家摇出了"+ currentpoint + "点");switch(currentpoint) {case 7:case 11:System.out.println("玩家胜!!!");money += n ;break;case 2:case 3:case 12:System.out.println("庄家胜!!!");money -= n;break;default:goon = true;}while (goon){currentpoint = roll() + roll();System.out.println("玩家摇出了" + currentpoint + "点");if(currentpoint == 7){System.out.println("庄家胜");money -= n;goon = false;}else if(currentpoint == firstpoint){System.out.println("玩家胜");money += n;goon = false; }}if(money == 0){System.out.println("你输完了!!!");}}}}
0 0
- Java 循环运算试题1
- Java循环运算--作业
- Java基础3--运算符--判断--循环
- Java中循环运算的小练习
- java—运算符,循环结构
- JAVA面试题,关于线程循环
- 第六届蓝桥杯java试题-循环节长度
- java面试题三 位运算符
- java关于位移运算的面试题
- java 运算符学习笔记 面试题
- Java数据类型与运算符面试题
- 经典Java面试题-Java中Char类型的运算
- 黑马程序员---java基础 -----基础知识,运算符,循环等
- java中的书写规范、条件运算符、循环语句
- Android day6:JAVA运算符、流程(循环)、数组
- java自学循环与选择性语句及表达式语句运算
- Java基本语句(运算符、条件控制语句、for循环
- Java SE学习笔记:运算符、流程控制语句、循环
- iwpriv
- Linux内核分析 - 网络[三]:从netif_receive_skb()说起
- Linux内核分析 - 网络[四]:路由表
- FZU 2091 播放器
- 解决hibernate+struts2+spring 在断网的情况下工程不能部署
- Java 循环运算试题1
- 怎么盗QQ密码,如何盗别人QQ密码最简单方法
- windows访问ubuntu上的共享文件夹
- MYSQL_ROW转wchar_t和CString
- 安卓调试时显示连接主机产生错误解决办法
- 图像二值化----otsu(最大类间方差法、大津算法)
- JavaScript创建元素函数库(个人研究使用)
- 【智能车新手入门】-位置式、增量式PID实现代码
- -java小知识点