28 3 月, 2026
#include<stdio.h>
int vis[20],a[20],n;
void dfs(int k){
	if(k==n){
		for(int i=0;i<=n;i++){
			printf("%d",a[i]);
		}
		printf("\n");
		return;
	}for(int i=1;i<=n;i++){
		if(!vis[i]){
			vis[i]=1;
			a[k]=i;
			dfs(k+1);
			vis[i]=0;
		}
	}
}
 int main(){
	n=3;
	dfs(0);
	 return 0;
 }

This entry was posted on 星期六, 28 3 月, 2026 at 下午10:29 and is filed under 未分类. You can follow any responses to this entry through the RSS 2.0 feed. Responses are currently closed, but you can trackback from your own site.

Comments are closed.