注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 利用IPSec实现网络安全之..
 帮助

随机生成double二维数组的源程序


2008-05-08 11:01:11
 标签:java   [推送到技术圈]

/*
 * Created on 2006-6-21
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.tiantian;
import java.util.Random;
//import java.math.*;

/**
 * @author Administrator
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class RandomArray {
    public static double[][] GetArray(int a, int b) {
        double num = 0;
        Random random = new Random();
        int number = random.nextInt(100);
        int i = 10;
        int j = 10;
        double[][] a2;
        if ((a != 0) && (b != 0))
            a2 = new double[a];
        else
            a2 = new double[1][1];
        for (i = 0; i < a2.length; i++)
            for (j = 0; j < a2[i].length; j++) {
                num = random.nextDouble();
                a2[i][j] = num;
            }
        return a2;
    }
    public static void main(String[] args) {
        //Random random = new Random();
        //double num = random.nextDouble();
        //System.out.println(number);
        double[][] a = RandomArray.GetArray(10, 10);
        for (int i = 0; i < a.length; i++)
            for (int j = 0; j < a[i].length; j++) {
                System.out.println(a[i][j]);
            }
    }
}




    文章评论
 
 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: