//随机输出二维数组
import java.util.Scanner;
public class Test21 {
public static void main(String[] args) {
while(true){
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
System.out.print("请输入一维数组个数:");
int a=in.nextInt();
System.out.print("请输入数组个数:");
int b=in.nextInt();
System.out.print("输出界限以内的随机数:");
int c=in.nextInt();
System.out.println("你输入的数组是:arr["+a+"]"+"["+b+"]");
int [][]arr=new int[a][b];
int[] arr1=new int[a];
int[] arr2=new int[b];
System.out.println("二维数组的具体值是:");
System.out.print("{");
for(int i=0;i<arr1.length;i++){
//System.out.print("arr["+i+"]=");
System.out.print("arr["+i+"]="+"{");
for(int j=0;j<arr2.length;j++){
arr2[j]=(int)(Math.random()*c);
System.out.print(arr2[j]+"\t");
}
System.out.println("}");
}
System.out.print("}");
System.out.println("是否继续查询:(y/n)");
String o=in.next();
if(o.equals("y")){
continue;
}
break;
}
}
}
|
|