Are there any better methods to do permutation of string?

前端 未结 20 1632
醉话见心
醉话见心 2020-11-27 11:15
void permute(string elems, int mid, int end)
{
    static int count;
    if (mid == end) {
        cout << ++count << \" : \" << elems << end         


        
20条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 11:49

    This is not the best logic, but then, i am a beginner. I'll be quite happy and obliged if anyone gives me suggestions on this code

    #include
    #include
    #include
    int c=1,j=1;
    
    
    int fact(int p,int l)
    {
    int f=1;
    for(j=1;j<=l;j++)
    {
    f=f*j;
    if(f==p)
    return 1;
    
    }
    return 0;
    }
    
    
    void rev(char *a,int q)
    {
    int l=strlen(a);
    int m=l-q;
    char t;
    for(int x=m,y=0;x>a;
    int f=1;
    
    for(int o=1;o<=strlen(a);o++)
    f=f*o;
    
    perm(a,f,0);
    getch();
    }
    

提交回复
热议问题