标签:ace lse als cli 合集 pen 图片 ros close
1.全排列
#include<bits/stdc++.h>
using namespace std;
int n = 3;
bool hashtable[100] = {false};
int P[100] = {-1};
int count_num = 0;
void f(int index){
if(index == n + 1){
for (int i = 1; i <= n; i++){
printf("%d ", P[i]);
}
count_num++;
printf("\n");
return;
}
for (int x = 1; x <= n; x++){
if (hashtable[x] == false){
P[index] = x;
hashtable[x] = true;
f(index + 1);
hashtable[x] = false;
}
}
}
int main(){
f(1);
printf("\ncount=%d", count_num);
return 0;
}
2.八皇后
(未完待续~)
标签:ace lse als cli 合集 pen 图片 ros close
原文地址:https://www.cnblogs.com/yellowzunzhi/p/11123045.html