题解 | #老子的全排列呢#

老子的全排列呢

https://ac.nowcoder.com/acm/problem/15128

dfs入门

public class Main{
    public static void main(String args[]){
        dfs(1,"");
    }
    public static void dfs(int depth,String ans){
        if(depth==9)   System.out.println(ans);
        for(int i = 1;i<=8;i++){
            if(!ans.contains(i+""))    dfs(depth+1,ans+i+" ");    
        }
    }
}
全部评论

相关推荐

04-01 16:02
已编辑
武汉工程大学 Java
牛客98843461...:处女面??我还种马面渣男面处男面呢
点赞 评论 收藏
分享
求好运眷顾🙏🏻:这是给自己开户了吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务