分享

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

 执着男孩 2006-09-13

    

/*
 * 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][b];
        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]);
            }
    }
}
 


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约