九月二十三日

动手动脑1

随机生成1000个随机数

public class Main {


    static int x=1;
    public  static void  f(int count)
    {
        for(int i=0;i<count;i++)
        {
            x=(16807 * x + 1) % Integer.MAX_VALUE;
            System.out.println(x);
        }
    }


    public static void main (String[] args)
    {
        int count=1000;
        f(count);
    }

}

 

动手动脑2

函数重载

public class Main {
    public static void main(String[] args) {
        System.out.println("The square of integer 7 is "+square(7));
        System.out.println("The square of double 7 is "+square(7.5));
    }
    
    public static int square(int x){
        return x*x;
    }
    
    public static double square(double x){
        return x*x;
    }
}

  

posted @ 2023-09-22 22:14  财神给你送元宝  阅读(14)  评论(0)    收藏  举报