package lianxi_1;
//随机输出数组
import java.util.*;
public class Test22 {
public static void main(String[] args) {
while(true){
Scanner in=new Scanner(System.in);
int num1,num2;
System.out.println("请输入数组包含的成员个数:");
num1=in.nextInt();
System.out.println("请限制输出数不超过的界限:");
num2=in.nextInt();
int arr[]=new int [num1];
System.out.print("{");
for(int i=0;i<arr.length;i++){
//arr[i]=i+5;
arr[i]=(int)(Math.random()*num2);
System.out.println("arr["+i+"]="+arr[i]);
/**
System.out.print("arr[]={");
int arr[]=new int [4];
int i;
for(i=0;i<arr.length;i++){
arr[i]=i+5;
System.out.print(+arr[i]+" ");
*/
}
System.out.print("}");
System.out.println("是否继续查询:(y/n)");
String o=in.next();
if(o.equals("y")){
continue;
}
break;
}
}
}
|
|