import java. util. Set;
import java. util. HashSet;
public class Zuhe {
static void lottery(int a[], int start_index, int end_index,
int needed_balls, SetInteger already_chosen) {
if (needed_balls == 0) {
System. out. println(already_chosen);
return;
}
for (int i = start_index; i = end_index - needed_balls + 1; i++) {
already_chosen. add(a
);
lottery(a, i + 1, end_index, needed_balls - 1, already_chosen);
already_chosen. remove(a);
}
}
public static void main(String[] args) {
lottery(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, 0, 9, 4,
new HashSetInteger());
}
}文章由记忆枕汉妮威整理,收集辛苦,希望能保留出处。