码迷,mamicode.com
首页 > 其他好文 > 详细

Day3

时间:2014-10-19 18:30:39      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   ar   java   for   sp   div   

 1 public class Study2 {
 2     public static void main(String[] args) {
 3         for (int x = 0; x <= 20; x++) {
 4             for (int y = 0; y <= 33; y++) {
 5                 for (int z = 0; z <= 100; z += 2) {
 6                     if (x + y + z == 100 && (5 * x + 3 * y + z / 3) == 100) {
 7                         System.out.printf("公鸡%d只\t" + "母鸡%d只\t" + "小鸡%d只\t",x,y,z);
 8                         System.out.println();
 9                     }
10                 }
11 
12             }
13 
14         }
15 
16     }
17 }
 1 import java.util.Scanner;
 2 
 3 public class Test2 {
 4     public static void main(String[] args) {
 5         Scanner sc = new Scanner(System.in);
 6         System.out.print("请输入投注数:");
 7         if (sc.hasNextInt()) {
 8             int n = sc.nextInt();
 9             if (n > 0) {
10                 for (int i = 1; i <= n; i++) {
11                     for (int j = 1; j <= 7; j++) {
12 
13                         System.out.print((int)( Math.random() * 10) + "");
14 
15                     }
16                     System.out.println();
17                 }
18             }
19 
20         }
21     }
22 }
 1 public class Test4 {
 2     public static int roll() {
 3         return (int) (Math.random() * 6 + 1);
 4     }
 5 
 6     public static void main(String[] args) {
 7         int a, b, sum = 1000;
 8         do{
 9         a = b = roll() + roll();
10         System.out.printf("你摇出了:%d点\n", b);
11         
12          
13             boolean goon = false;
14             switch (b) {
15             case 7:
16             case 11:
17                 System.out.println("you win");
18                 sum += 100;
19                 break;
20 
21             case 2:
22             case 3:
23             case 12:
24                 System.out.println("you lose");
25                 sum -= 100;
26                 break;
27 
28             default:
29                 goon = true;
30             }
31             while (goon) {
32                 b = roll() + roll();
33                 System.out.printf("你摇出了:%d点\n", b);
34                 if (b == 7) {
35                     System.out.println("you lose");
36                     sum -= 100;
37                     goon=false;        
38                 } else if (b == a) {
39                     System.out.println("you win");
40                     sum -= 100;
41                     goon=false;
42                 }
43             }
44 
45         } while (sum > 0);
46 
47         System.out.println("你输完了");
48 
49     }
50 }

 

 

 

Day3

标签:style   blog   color   os   ar   java   for   sp   div   

原文地址:http://www.cnblogs.com/shuangyue/p/4035128.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!