文章

285

粉丝

20

获赞

888

访问

320.2k

头像
全排列 题解:y总板子套的题解,不错

#include<bits/stdc++.h>
using namespace std;

const int N=10;
int n;
bool st[N];
char path[N];

void dfs(int u,string str)
{
    if(u==n)
    {
        for(int i=0;i<n;i++)
            cout<<path[i];
        cout<<endl;
    }
    
    for(int i=0;i<n;i++)
    {
        if(!st[i])
        {
            path[u]=str[i];
            st[i]=true;
            dfs(u+1,str);
            st[i]=false;
        }
    }
    return;
}

int main()
{
 &n...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发