08/08/12 13:57:38
どう考えても再帰のほうが楽
#include<stdio.h>
void go(){
int i=0,flag=0,j_[3];
char s[4];
j_[0]=-1;s[3]=0;
do for(flag &= ~(1<<j_[i]);++j_[i]<6;)
if(!(flag&1<<j_[i])){
s[i]=j_[i]+'A';
if(i+1==3)puts(s);
else{
flag |= 1<<j_[i++];
j_[i]=-1;
}
}
while(i--);
}
int main(void){
go();
return 0;
}