Untitled

                Never    
C
       
#include <stdio.h>
#include <string.h>
char given_list[20];        //use given_list to store the input
char password[20];          //use passward to store the output
int len;

void list();
void perm(int pos,int start,int end);
//pos is for the currant position of password[]
//start~end is for the range of given_list[]

int main(void){
    scanf("%s",given_list);
    len=strlen(given_list);
    list();
    perm(0,0,len-1);
    return 0;
}

void perm(int pos,int start,int end){
    int i;
    //printf("start:%d\n",start);
    //basic step
    if(pos>=4 && pos<=len){
        for(int j=0;j<pos;j++)
            printf("%c",password[j]);
        if(password[0]!=given_list[(len-4)])
            printf(",");
        else
            printf("\n");
    }
    //recursive step
    for(i=start;i<=end;i++){
        password[pos]=given_list[i];
        //printf("pos:%d %c ",pos,password[pos]);
        perm(pos+1,i+1,end);
    }
}

/*******bubble sort*******/
void list(void){
    char temp;
    for(int i=0;i<len-1; i++) {
            for (int j=0; j<len-1-i;j++) {
                  if (given_list[j]>given_list[j+1]) {
                       temp=given_list[j];
                        given_list[j]=given_list[j + 1];
                       given_list[j+1]=temp;
                  }
            }
      } 
}

Raw Text