全排列问题:
实现C代码:
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
int n;
int p[100];
int hashtable[100] = {false};
void generatep(int index) {
if (index==n+1)
{
for (int i = 1; i <= n; i++) {
printf("%d", p[i]);
}
printf("\n");
}
for (int x = 1; x <= n; x++) {
if (hashtable[x] == false)
{
p[index] = x;
hashtable[x] = true;
generatep(index+1);
hashtable[x] = false;
}
}
}
int main() {
n = 3;
generatep(1);
return 0;
}