100¥求100只因

100¥求100只因

package com.Mxhlin.demo;

/**
 * @author Mxhlin
 * @Email fuhua277@163.com
 * @Date 2022/09/05/20:01
 * @Version
 * @Description 公只因 5¥一只,母只因3¥一只,小只因1¥三只
 */
public class100or100只因 {
    public static void main(String[] args) {
        int a = 0;// 公只因
        int b = 0;// 母只因
        int c = 0;// 小只因
        for (a = 0;a<=20;a++){
            for (b = 0;b<=33;b++){
                c = 100-a-b;// 小只因的数量
                if (a*5+b*3+c/3==100&&c%3==0){
                    System.out.printf("公只因 %d 母只因 %d 小只因 %d %n",a,b,c);
                }
            }
        }

    }
}

双色球

package com.Mxhlin.demo;

import java.util.Random;

/**
 * @author Mxhlin
 * @Email fuhua277@163.com
 * @Date 2022/09/05/20:38
 * @Version
 * @Description 双色球
 */
public class two_colorBall220905 {
    public static void main(String[] args) {
        Random random = new Random();
        for (int i = 0; i < 10; i++) {


            int a1 = 0;
            int a2 = 0;
            int a3 = 0;
            int a4 = 0;
            int a5 = 0;
            int a6 = 0;

            int index = 0;
            while (true) {
                int t = random.nextInt(1, 33);
                ++index;
                if (index == 1) {
                    a1 = t;
                    System.out.printf("%d  ", a1);
                    continue;
                } else if (index == 2 && t != a1) {
                    a2 = t;
                    System.out.printf("%d  ", a2);
                    continue;
                } else if (index == 3 && t != a2 && t != a1) {
                    a3 = t;
                    System.out.printf("%d  ", a3);
                    continue;
                } else if (index == 4 && t != a3 && t != a2 && t != a1) {
                    a4 = t;
                    System.out.printf("%d  ", a4);
                    continue;
                } else if (index == 5 && t != a4 && t != a3 && t != a2 && t != a1) {
                    a5 = t;
                    System.out.printf("%d  ", a5);
                    continue;
                } else if (index == 6 && t != a5 && t != a4 && t != a3 && t != a2 && t != a1) {
                    a6 = t;
                    System.out.printf("%d  ", a6);
                    continue;
                } else {
                    --index;
                }
                if (index == 6) {
                    System.out.println();
                    break;
                }
            }
        }
    }
}

求素数

package com.Mxhlin.demo;

/**
 * @author Mxhlin
 * @Email fuhua277@163.com
 * @Date 2022/09/05/21:01
 * @Version
 * @Description
 */
public class Sushu220905 {
    public static void main(String[] args) {
        for (int i = 0; i <= 100; i++) {
            if (i == 2 || i == 3 || i == 5 || i == 7) {
                System.out.print(i + " ");
                continue;
            }
            if (i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0) {
                System.out.print(i + " ");
            }
        }
    }
}

求1970 ~ 2022 之间的闰年

package com.Mxhlin.demo;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;

/**
 * @author Mxhlin
 * @Email fuhua277@163.com
 * @Date 2022/09/05/19:43
 * @Version
 * @Description
 */
public class LeapYearToNow220905 {
    public static void main(String[] args) {
        // Calendar calendar = Calendar.getInstance();
        // calendar.set(Calendar.YEAR, 1970);
        // int end = calendar.get(Calendar.YEAR);
        //
        // LocalDate ld = LocalDate.now();
        // int year = ld.getYear();

        int sum = 0;

        for (int i = 1970; i <= 2022; i++) {
            // 计算1970 ~~ 2022 之间有多少闰年
            if (i % 400 == 0 || i % 4 == 0 && i % 100 != 0) {
                sum++;
            }
        }
        System.out.printf("1970~2022之间的闰年有 %d个年", sum);
    }
}

猜数字游戏

package com.Mxhlin.demo;

import java.util.Random;
import java.util.Scanner;

/**
 * @author Mxhlin
 * @Email fuhua277@163.com
 * @Date 2022/09/02/19:33
 * @Version
 * @Description  猜数字游戏
 */
public class GuessNumber {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("游戏分为十个难度!!!");
        System.out.print("请选择游戏难度:");
        int i = Integer.parseInt(sc.nextLine());

            int start = 1;
            int[] difficulty = {100,200,300,400,500,600,700,800,900,1000};
            int end = difficulty[i-1];
            // 生成两数之间的随机数
            Random random = new Random();
            long l = random.nextLong(start, end);
            System.out.printf("你选择的难度为%d级  %d ~ %d%n",i,start,end);
            System.out.printf("%d ~ %d输入你要猜的数字: ",start,end);


        int c =0;
        while (true) {
            int choose = Integer.parseInt(sc.nextLine());

                c++;
                if (choose == l) {
                    System.out.println("恭喜你 猜对啦!!");
                    break;
                } else if (choose < l) {
                    System.out.printf("%d.小了 请继续!%n", c);
                } else if (choose > l) {
                    System.out.printf("%d.大了 请继续!%n", c);
                }

                if (c > 10) {
                    System.out.println("你太菜了!!! ");
                    break;
                }
            }


    }
}

输出菱形

package com.Mxhlin.demo;

/**
 * @author Mxhlin
 * @Email fuhua277@163.com
 * @Date 2022/09/05/15:15
 * @Version
 * @Description    for循环输出菱形
 */

/**
 *
 *
 @@@*
 @@***
 @*****
  *******

 行        星星       @
 1          1        3
 2          3        2
 3          5        1
 4          7        0
 未知 的数   *  行号*2-1
            @  行数-行号
 */
public class ForDemo06 {
    public static void main(String[] args) {
        int maxLine = 8;
        for (int i = 1; i <=maxLine ; i++) {
            for (int j = 1; j <=maxLine-i ; j++) {
                System.out.print(" ");
            }
            for (int j = 1; j <=i*2-1 ; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
        for (int i = maxLine-1; i >=1 ; i--) {
            for (int j = 1; j <=maxLine-i ; j++) {
                System.out.print(" ");
            }
            for (int j = 1; j <=i*2-1 ; j++) {
                System.out.print("*");
            }
            System.out.println();
        }


    }
}

九九乘法表

package com.Mxhlin.demo;

import java.util.Scanner;

/**
 * @author Mxhlin
 * @Email fuhua277@163.com
 * @Date 2022/09/05/14:05
 * @Version
 * @Description 九九乘法表
 */
public class ForDemo04 {
    public static void main(String[] args) {
        for (int i = 1; i <=9; i++) {
            for (int b = 1 ;b <=i;b++){
                System.out.printf("%d * %d = %2d  ",i,b,i*b);
            }
            System.out.println();
        }

    }
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值