赞
踩
import java.util.Random;
public class GetNum {
public static int i = 0;
public static void main(String[] args) {
Random r = new Random();
int arr[] = new int[10];
int temp = 0;
for (; i < 10;) {
temp = r.nextInt(100);//生成10个0-100的数
if (i == 0) {
arr[i] = temp;
i++;
} else {
for (int j = 0; j < i; j++) {
if (arr[j] == temp) {
break;
} else if (j == i - 1) {//判断所有的arr[j]是否都不等于temp,不等就把temp赋值给arr[i]
arr[i] = temp;
i++;
// break;
}
}
}
}
for (int n = 0; n < arr.length; n++) {//对你取的10个随机数排序
for (int j = n + 1; j < 10; j++) {
if (arr[n] >
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。