首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
路西法
2025年3月25日 16:57
全排列 题解:借用next_permutation函数
P1185
回复 0
|
赞 2
|
浏览 457
提前打印一个本身 #include<stdio.h> #include<algorithm> #include<string.h> using namespace std; int main(){ char a[10]; gets(a); int n=strlen(a); string str1=a; printf("%s\n&...
诗岸梦行舟
2025年3月13日 22:13
全排列 题解:全排列数字,用数字做索引
P1185
回复 2
|
赞 10
|
浏览 626
#include<stdio.h> #include<stdlib.h> #include<string.h> int n,a[10],book[10]={0}; char s[11]; void dfs(int step){ if(step==n){ for(int i=0;i<n;i++){ printf("%c",s[a[i]]); } printf("\n"); return; } for(int i=1;i<=n;i++){ if(book[i]==0){ ...
chenxx
2025年3月8日 15:16
全排列 题解:
P1185
回复 0
|
赞 4
|
浏览 455
#include<string> #include<iostream> using namespace std; struct node{ char name; int visit; //node(char nn):name(nn),visit(0){} }; // 全排列函数 void fa(int num, node s[], char ans[], int len){ if (nu...
youzi
2025年3月7日 00:00
全排列 题解:递归
P1185
回复 0
|
赞 11
|
浏览 694
#include <stdio.h> #include <string.h> void print(char *s, char *res, int index, int len){ if(index == len){ res[index] = '\0'; printf("%s\n",res); }else{  ...
MEGURI
2025年1月6日 10:57
全排列 题解:迭代方式生成全排列
P1185
回复 0
|
赞 6
|
浏览 711
#include <stdio.h> #include <string.h> // 交换两个字符 void swap(char *x, char *y) { char temp = *x; *x = *y; *y = temp; } // 检查是否为下一个排列 int next(char *str, int length) { int i = length - 2; &nb...
Howie_Waves
2024年9月3日 19:27
全排列 题解:
P1185
回复 0
|
赞 13
|
浏览 2.2k
按照这个回溯法的模板来吧(DFS也是这个模板) result = [] def backtrack(路径, 选择列表): if 满足结束条件: result.add(路径) return for 选择 in 选择列表: 做选择 backtrack(路径, ...
wut to hust
2024年8月17日 16:37
全排列 调用C++库函数
P1185
回复 0
|
赞 23
|
浏览 1.1k
#include<bits/stdc++.h> using namespace std; int main() { string s; cin >> s; char a[10]; int n=s.size(); for(int i=0;i<n;i++) a[i]=s[i]; &...
iRR
2024年7月5日 11:21
全排列 题解:
P1185
回复 0
|
赞 2
|
浏览 1.0k
#include<bits/stdc++.h> using namespace std; int N; string ans; int bl[7]; void dfs(int n,string s) { if(n == N) { for(int i = 0;i<N;i++) { cout<<ans[i]; } cout<<endl; return ; } for(int i = 0;i<N;i++) { if(!bl[i]){ ans[n]...
Candour
2024年5月30日 19:26
全排列(dfs搜索) 题解:
P1185
回复 0
|
赞 8
|
浏览 976
#include<bits/stdc++.h> using namespace std; string str, res; int n; bool st[10]; void dfs(int u) { if(u >= n) { cout << res << endl; return ; } for(int i = 0; i < n; i ++) { if(!st[i]) { res.push_back(str[i]); st[i] = true; ...
拉萨小队长
2024年4月26日 17:56
全排列 题解:DFS自用笔记,带详细注释
P1185
回复 0
|
赞 18
|
浏览 1.6k
#include<bits/stdc++.h> using namespace std; int card[100]; // 标记手里的字符:0表示此字符还在手里,1表示此字符已出 char res[100]; // 记录字符顺序 void dfs(int step, char* str){ int len=strlen(str); if(step==len) &nb...
1
2
3
题目
全排列
题解数量
23
发布题解
在线答疑
热门题解
1
全排列 调用C++库函数
2
全排列 题解:DFS自用笔记,带详细注释
3
全排列 题解:新手易于理解模板(B站视频套用)
4
全排列 题解:
5
全排列 题解:递归
6
全排列 题解:全排列数字,用数字做索引
7
全排列(dfs搜索) 题解:
8
全排列 题解:迭代方式生成全排列
9
全排列 题解:
10
P1185 全排列 #vector #dfs