package L4;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class L9 {
static char[] c = new char[3];
static int in = 0;
// 组合枚举
// index 元素位置
// k 选取的元素个数
// arr 数组
static void com(int index, int k, char[] arr) {
if (k == 0) {
System.out.println(Arrays.toString(c));
return;
}
for (int i = index; i < arr.length; i++) {
c[in++] = arr[i];//暂时存储元素
com(i + 1, k - 1, arr);//从选取得元素后面选取下一个,避免重复
in--;
c[in] = '0';//回溯
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
char[] s = "ABCD".toCharArray();
com(0, 3, s);
}
}
public class CB7 {
static int[] nums = { 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14 };
static int[] c = new int[5];
static int cnt = 0;
public static void main(String[] args) {
// TODO Auto-generated method stub
cbt(0, 5);
System.out.println("cnt:" + cnt);
}
public static boolean isok() {
}
// low代表起始位,num代表取出的数字
public static void cbt(int low, int num) {
// 出口
if (num == 0) {
// 条件判断
if (isok()) {
cnt++;
}
return;
}
for (int i = low; i < nums.length; i++) {
c[num - 1] = nums[i];
cbt(i + 1, num - 1);
}
}
}
static int n;// 从n个数里选出m个数
static int m;
static void cbt() {
int cntm = 0;
for (int i = 0; i < (1 << n); i++) {
for (int j = 0; j < n; j++) {
if ((1 & (1 << j)) == 1) {
// 这个位置选中
cntm++;
}
}
if (cntm == m) {
// 选出的结果
}
}
}