//
//创建一个长度为6的int型随机数数组,要求取值为1-30,且元素各不相同
//取[a,b]随机整数:(int)(Math.random()*(b-a+1)+a)
public class Arrayexer1 {
public static void main(String[] args) {
int[] arr = new int[6];
for (int i = 0; i < arr.length; i++) {
arr[i] = (int)(Math.random()*30+1);
for (int j = 0; j < i; j++) {
if (arr[i] == arr[j]) {
i--;
break;
}
}
}
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
}
}