我在openGL中实现了一个从0到9的数字圈,但在序列中,我想要一个公式来将数字非顺序地排列在一个圆内。例如,在2之后的4,然后9或任何数字跟随其他的,但它必须是un序列。
请尽快帮助我!
发布于 2015-05-11 12:40:57
把你的数字放在一个数组中,而不是像下面这样对它们进行洗牌。
public class ShuffleDemo {
public static void main(String args[]) {
// create array list object
List arrlist = new ArrayList();
// populate the list 0 to 9
for(int i = 0, i<=9; i++ ){
arrlist.add(i);
}
System.out.println("Initial collection: "+arrlist);
// shuffle the list
Collections.shuffle(arrlist);
System.out.println("Final collection after shuffle: "+arrlist);
}
} https://stackoverflow.com/questions/30166138
复制相似问题