动手又动脑 2018/10/14

(1)

package test2;
/*
 * 产生指定书目的随机整数
 * 杨瑞 2018/10/14
 */
public class RandomTest {
 public static final int MAX=100; //MAX相当于常量
 public long a=12345L;
 public long c=12345L;
 public long m=12365L;
 public long x=1;
 //随机数生成器
 public long rand() {
  x=(x*a+c)%m;
  return x;
 }
 public static void main(String []args) {
  
  RandomTest s=new RandomTest();
  long r;
  for(int i=0;i<MAX;) {
   r=s.rand();
   System.out.print(r+" ");
   i++;
   if(i%10==0)
    System.out.println();
  }
  
 }
}
(2)我发现了这个方法用了重载的方法。

(3)我发现了这个方法也是用了重载的方法。

 
 
 
 

猜你喜欢

转载自www.cnblogs.com/qianmo123/p/9786786.html