![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
#include <stdio.h>
#define MAX 10
int used[MAX];
int result[MAX];
int N;
void print(){
int i;
for(i = 0; i < N; i++)
printf("%d ", result[i]);
printf("\n");
}
void proc(int step)
{
int i;
if(step == N)
print();
else
{
for(i = 0; i < N; i++)
{
if(!used[i])
{
used[i] = 1;
result[step] = i + 1;
proc(step + 1);
used[i] = 0;
}
}
}
}
main(){
scanf("%d", &N);
proc(0);
getch();
} ![](https://www.cnblogs.com/Emoticons/tusiji/203707340.gif)
![](https://www.cnblogs.com/Emoticons/tusiji/203707340.gif)
posted on
2009-05-28 23:51
Jesus Program
阅读(
123)
评论()
编辑
收藏
举报