|
我想地太简单了么?
- import java.util.Random;
- public class Random_circle {
- Random r;
- double x,y,temp;
- Random_circle(int i){// i is the number of pairs you want
- r = new Random();
- while(i>0){
- x=random();
- y=random();
- temp = (Math.sqrt(Math.pow(x,2)+Math.pow(y,2)));
- if(temp<=1)
- output(x,y);
- i--;
- }
- }
- private double random(){
- return r.nextDouble();
- }
- private void output(double x, double y){
- System.out.println("("+x+","+y+")");
- }
- public static void main(String[] args){
- Random_circle rc = new Random_circle(100);
- }
- }
复制代码 |
|