例如8,9,7,1,2,5,4,3,6,10
1,4,8,9,5,6,3,2,10
1,4,8,9,5,6,3,2,10
解决方案 »
- String 转化Unicode 出现的问题
- 大家给看看哪里出了问题,用snmp4j访问mib
- 什么是抛出异常?以及为什么要抛出异常?
- 瞬联、ibm面试题,大家来答答看!!!
- Java对Oracle数据库中的信息进行增删改后, 要进行commit提交吗? 要的话怎么执行?
- 自定义标签传值问题,急!
- String类保存中文问题
- 帮忙,100就给一人
- 删除文本中一段类容
- ********************我现在在SOLARIS上安装了ORACLE8I,我想建立数据库,但我有一个问题一直没有解决,请大家进来看看!****************
- ttf 字体解析类库,谁有?解析完后要显示出来,
- 关于正则的小问题--只有一条不明白
public static void main(String[] args) {
Set<Integer> set = new HashSet<Integer>();
Random random = new Random();
while(set.size() != 10){
random.setSeed(System.currentTimeMillis());
set.add(random.nextInt(10)+1);
}
System.out.println(set);
}
// 1~10的随机10个不同的数
int a[] = new int[10];
a[0] = (int) (Math.random() * 10) + 1;
for (int i = 1; i < a.length;) {
int t = (int) (Math.random() * 10) + 1; // 1~29
boolean f = true;
for (int j = 0; j < i; j++) {
if (t == a[j]) {
f = false;
break;
}
}
if (f) {
a[i] = t;
i++;
} } // 结果显示
for (int i = 0; i < a.length ; i++) {
System.out.print(a[i] + "\t");
}
}}
public class TestRamdom{
public static void main(String[] args){
int i=0;
for(int x=0;x<10;x++)
{
i=(int)(Math.random()*10+1);
System.out.println(i);
}
}
}
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i=0; i<10; i++)
list.add(i+1);
while(!list.isEmpty())
System.out.print(list.remove((int)(Math.random()*list.size())) + " ");
for (int i = 0; i < 10; i++)
list.add(i + 1); while (!list.isEmpty())
System.out.print(list.remove((int) (Math.random() * list.size())) + " ");
你这个我直接用DOS运行不了···我才疏学浅
刚学JAVA···code 是什么 我不是很懂3··
import java.util.Random;/**
*
* @author Hu Linhua
*
*/
public class RandomNumTest {
public static void main(String[] args) {
ArrayList<Integer> arr = new ArrayList<Integer>();
while(arr.size() != 10) {
int num = new Random().nextInt(10);
if( !arr.contains(num)) {
arr.add(num);
}
}
for(Integer j:arr) {
System.out.println(j);
}
}
}
package math;import java.util.ArrayList;
import java.util.Random;/**
*
* @author Hu Linhua
*
*/
public class RandomNumTest {
public static void main(String[] args) {
ArrayList<Integer> arr = new ArrayList<Integer>();
while(arr.size() != 10) {
int num = new Random().nextInt(10);
if( !arr.contains(num)) {
arr.add(num);
}
}
for(Integer j:arr) {
System.out.println(j);
}
}
}