자료구조. 순열순환생성기 질문드립니당.
도널드
2023.04.01
질문 제목 :
순환순열생성기 질문이요.
질문 내용 :
#include stdio.h
#define swap(x,y,t)((t)=(x),(x)=(y),(y)=(t));
void perm(char*list, int i, int n);
void main(void){
char list[]=1bc;
perm(list,0,2);
printf(\n);
}
void perm(char *list, int i,int n){
int j;
int temp;
if(i==n){
for(j=0;j=n;j++)
printf(%c,list[i]);
printf( );
}
else{
for(j=i;j=n;j++){
swap(list[i],list[j],temp);
perm(list,i+1,n);
swap(list[i],list[j],temp);
}
}
}
인데용.. perm함수가 이해가 잘 안가네용..
실행해보면
ccc bbb ccc 111 111 bbb
이렇게 나오는데 어떻해 나오는지 설명좀 부탁드립니다..