摘要:
#define N 10int lis[N+1][N+1];int *LIS(int *a){ for (int i=1; i<=N; i++) { lis[i][0]=1; lis[i][1]=a[i]; for (int j=1;j<i; j++) { if (a[i]>lis[j][lis[j][0]]) { lis[j][0]++; lis[j][lis[j][0]] = a[i]; } ... 阅读全文
摘要:
N个数中选M个数的组合问题#define N 5#define M 4char answer[N];void Print(char a[], int n){ for (int i=0; i<n; i++) { cout << a[i] << " "; } cout << endl;}void Combination(char a[], int b, int n, int k){ if (k == 0) { Print(answer, M); return; } if (k==n) { ... 阅读全文