zoukankan      html  css  js  c++  java
  • 11~15

    11,含不同数字的三位数:

    public class ThridNum {
        public static void main(String[] args) {
            int count = 0;
            for (int x = 1; x < 5; x++) {
                for (int y = 1; y < 5; y++) {
                    for (int z = 1; z < 5; z++) {
                        if (x != y && y != z && x != z) {
                            count++;
                            System.out.println(x * 100 + y * 10 + z);
                        }
                    }
                }
            }
            System.out.println("All have " + count + " thrrir numbers.");
        }
    }

    12,求奖金数:

    import java.util.Scanner;

    public class Bonus {
        public static void main(String[] args) {
            System.out.println("Please input the gain this year: ");
            Scanner scanner = new Scanner(System.in);
            int Gain = scanner.nextInt();
            int Bonus;
            if (Gain <= 100000) {
                Bonus=(int) (Gain * 0.1);
                System.out.println("The bonus is: " +Bonus );
            } else if (Gain <= 200000) {
                Bonus=(int)(10000 + (Gain - 100000)    * 0.075);
                System.out.println("The bonus is: " + Bonus);
            } else if (Gain <= 400000) {
                Bonus=(int)(10000 + 7500+ (Gain - 200000) * 0.05);
                System.out.println("The bonus is: " + Bonus);
            } else if (Gain <= 600000) {
                Bonus=(int)(10000 + 7500 + 10000+ (Gain - 400000) * 0.03);
                System.out.println("The bonus is: " + Bonus);
            } else if (Gain <= 1000000) {
                Bonus=(int)(10000 + 7500 + 10000 + 6000+ (Gain - 600000) * 0.015);
                System.out.println("The bonus is: " + Bonus);
            } else {
                Bonus=(int)(10000 + 7500 + 10000 + 6000+ 6000 + (Gain - 1000000) * 0.01);
                System.out.println("The bonus is: " + Bonus);
            }
        }
    }

    13,求100000内的完全平方数:

    public class FullSquareNum {
        public static void main(String[] args) {
            for (int i = 0; i < 100000; i++) {

    //一个数的平方根如果是个整数,则该数是完全平方数
                if (Math.sqrt(i + 100) % 1 == 0 && Math.sqrt(i + 268) % 1 == 0) {
                    System.out.println(i + " IS FULL SQURE NUMBER.");
                }
            }
        }
    }

  • 相关阅读:
    [PHP] php调用不存在的方法会自动调用 __call 魔术方法
    [PHP] laravel框架响应json信息中文禁止unicode编码
    [PHP] php中的trait代码复用方式
    [nginx] 解决:upstream timed out (110: Connection timed out) while reading response header from upstream
    [linux] Linux下格式化JSON程序-jq
    [git] Git Clean 清除 untrack 没有加入版本库的文件
    goland终端如何导入github上的包
    calico 配置 BGP Route Reflectors
    改善 Kubernetes 上的 JVM 预热问题
    golang开源对象存储
  • 原文地址:https://www.cnblogs.com/vonk/p/3993314.html
Copyright © 2011-2022 走看看