乱七八糟代码合集٩(๑>◡<๑)۶
作者:互联网
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.八皇后
(未完待续~)
标签:std,index,排列,int,乱七八糟,count,100,合集,代码 来源: https://www.cnblogs.com/yellowzunzhi/p/11123045.html