蓝桥杯手链样式 next

    xiaoxiao2021-03-25  110

    #include<iostream> #include<stdio.h> #include<string> #include<vector> #include<algorithm> using namespace std; string reco[30000]; int main(){ int res=0; string str="aaabbbbccccc"; string str2; int i; int lenth=str.length(); int flag=0; str2=str; str2+=str2; reco[res*2]=str2; reverse(str2.begin(),str2.end()); reco[res*2+1]=str2; res++; while(next_permutation(str.begin(),str.end())){ flag=1; for(i=0;i<res*2;i++) if(reco[i].find(str)!=string::npos) flag=0; if(flag==1){ str2=str; str2+=str2; reco[res*2]=str2; reverse(str2.begin(),str2.end()); reco[res*2+1]=str2; res++; } } cout<<res<<endl; }
    转载请注明原文地址: https://ju.6miu.com/read-12509.html

    最新回复(0)