public class RondamIntGenerator
{
public RondamIntGenerator(int l,int h)
{
high=h;
low=l;
}
public int draw()
{
int r=low+(int)((high -low +1)*nextRandom());
if(r>high) r=high;
return r;
}
public static void main(String args[])
{
RondamIntGenerator r1=new RondamIntGenerator(1,10);
RondamIntGenerator r2=new RondamIntGenerator(0,1);
int i;
for(i=0;i<=100;i++)
System.out.println(r1.draw()+" "+r2.draw());
}
private static double nextRandom()
{
int pos=(int)(java.lang.Math.random()*BUFFER_SIZE);
if (pos==BUFFER_SIZE) pos=BUFFER_SIZE-1;
double r=buffer[pos];
buffer[pos]=java.lang.Math.random();
return r;
}
private static final int BUFFER_SIZE=101;
private static double[] buffer=new double[BUFFER_SIZE];
static
{
int i;
for(i=0;i<BUFFER_SIZE;i++)
buffer[i]=java.lang.Math.random();
}
private int low;
private int high;
}
{
public RondamIntGenerator(int l,int h)
{
high=h;
low=l;
}
public int draw()
{
int r=low+(int)((high -low +1)*nextRandom());
if(r>high) r=high;
return r;
}
public static void main(String args[])
{
RondamIntGenerator r1=new RondamIntGenerator(1,10);
RondamIntGenerator r2=new RondamIntGenerator(0,1);
int i;
for(i=0;i<=100;i++)
System.out.println(r1.draw()+" "+r2.draw());
}
private static double nextRandom()
{
int pos=(int)(java.lang.Math.random()*BUFFER_SIZE);
if (pos==BUFFER_SIZE) pos=BUFFER_SIZE-1;
double r=buffer[pos];
buffer[pos]=java.lang.Math.random();
return r;
}
private static final int BUFFER_SIZE=101;
private static double[] buffer=new double[BUFFER_SIZE];
static
{
int i;
for(i=0;i<BUFFER_SIZE;i++)
buffer[i]=java.lang.Math.random();
}
private int low;
private int high;
}
{
public static final int BUFFER_SIZE=101;
public static double[] buffer=new double[BUFFER_SIZE];
static
{
int i;
for(i=0;i<BUFFER_SIZE;i++)
buffer[i]=java.lang.Math.random();}
private int low;
private int high;
public RondamIntGenerator(int l,int h)
{
high=h;
low=l; }
public int draw()
{
int r=low+(int)((high -low +1)*nextRandom());
if(r>high) r=high;
return r; }
public static void main(String args[])
{
RondamIntGenerator r1=new RondamIntGenerator(1,10);
RondamIntGenerator r2=new RondamIntGenerator(0,1);
int i;
for(i=0;i<=100;i++) System.out.println(r1.draw()+" "+r2.draw()); } private static double nextRandom()
{
int pos=(int)(java.lang.Math.random()*BUFFER_SIZE);
if (pos==BUFFER_SIZE) pos=BUFFER_SIZE-1;
double r=buffer[pos];
buffer[pos]=java.lang.Math.random();
return r; }
}
{
public RondamIntGenerator(int l,int h)
{
high=h;
low=l;
}
public int draw()
{
int r=low+(int)((high -low +1)*nextRandom());
if(r>high) r=high;
return r;
}
public static void main(String args[])
{
RondamIntGenerator r1=new RondamIntGenerator(1,10);
RondamIntGenerator r2=new RondamIntGenerator(0,1);
int i;
for(i=0;i<=100;i++)
System.out.println(r1.draw()+" "+r2.draw());
}
private static double nextRandom()
{
int pos=(int)(java.lang.Math.random()*BUFFER_SIZE);
if (pos==BUFFER_SIZE) pos=BUFFER_SIZE-1;
double r=buffer[pos];
buffer[pos]=java.lang.Math.random();
return r;
}
private static final int BUFFER_SIZE=101;
private static double[] buffer=new double[BUFFER_SIZE];
static
{
int i;
for(i=0;i<BUFFER_SIZE;i++)
buffer[i]=java.lang.Math.random();
}
private int low;
private int high;
}
private static double[]buffer=new double[BUFFER_SIZE];
private int low;
private int high; public RondamIntGenerator(int l,int h) {
high=h;
low=l;
}
public int draw() {
int r=low+(int)((high -low +1)*nextRandom());
if(r>high) r=high;
return r;
}
public static void main(String args[]) {
RondamIntGenerator r1=new RondamIntGenerator(1,10);
RondamIntGenerator r2=new RondamIntGenerator(0,1);
int i;
for(i=0;i<=100;i++)
System.out.println(r1.draw()+" "+r2.draw());
}
private static double nextRandom() {
int pos=(int)(java.lang.Math.random()*BUFFER_SIZE);
if (pos==BUFFER_SIZE) pos=BUFFER_SIZE-1;
double r=buffer[pos];
buffer[pos]=java.lang.Math.random();
return r;
}
static {
int i;
for(i=0;i<BUFFER_SIZE;i++)
buffer[i]=java.lang.Math.random();
}
} 调好了,主要是你写错的太多,把我改的跟你的比比,要注意阿,不要写错了。
Starting application C:\WINNT\Profiles\lizhaosong\Desktop\RondamIntGenerator.class
5 0
3 1
2 0
3 0
7 0
8 0
8 1
10 0
8 0
10 0
7 1
10 0
4 0
6 0
1 1
8 1
9 1
8 1
5 1
4 1
5 0
1 0
3 0
4 1
10 0
7 0
8 0
9 1
1 0
4 1
9 0
4 1
10 1
5 0
7 1
2 1
9 1
8 0
4 0
5 1
10 0
7 1
5 0
10 0
10 1
9 1
3 1
7 0
8 1
7 0
5 1
10 1
5 0
7 0
10 1
7 0
10 1
5 1
7 1
6 1
1 0
1 0
7 1
8 1
9 1
9 0
4 1
6 1
6 0
5 1
10 0
7 0
6 0
2 1
7 1
4 0
8 0
2 1
1 1
2 0
4 0
7 0
8 1
3 0
4 1
4 1
9 0
4 1
3 0
10 1
1 0
10 1
Interactive Session Ended
9 0
9 1
10 1
4 0
4 1
2 0
5 1
3 1
9 1