, , :
public static List<Integer> shuffled8() {
List<Integer> list = new ArrayList<Integer>();
for (int i = 1; i <= 8; i++) {
list.add(i);
}
Collections.shuffle(list);
return list;
}
public static void main(String[] args) {
List<Integer> first = shuffled8();
List<Integer> second= shuffled8();
for (int i = 0; i < 8; i++) {
System.out.println(first.get(i) + " " + second.get(i));
}
}
shuffled8 1 8, . , first second. first.get(i) second.get(i), .
To summarize this, if you need triplets, you simply add List<Integer> third = shuffled8();, and then first.get(i), second.get(i), third.get(i)this is a triplet that has the necessary properties.
source
share