problemscpp
A collection of my answers to algorithm problems in c++.
函数
acwing::acwing3429 命名空间参考

  1. 全排列
更多...

函数

void dfs (vector< char > &stk, int p, ostream &cout, string s)
 
int main (istream &cin, ostream &cout)
 
 TEST (acwing3429, case1)
 

详细描述

  1. 全排列

函数说明

◆ dfs()

void acwing::acwing3429::dfs ( vector< char > &  stk,
int  p,
ostream &  cout,
string  s 
)

在文件 acwing408.cpp657 行定义.

657 {
658 if(p == s.length()) {
659 for(char c: stk) {
660 cout << c;
661 }
662 cout << endl;
663 return;
664 }
665 for(int i = 0; i < s.length(); i++) {
666 bool contain = false;
667 for(int j = 0; j < p; j++) {
668 if(stk[j] == s[i]) {
669 contain = true;
670 break;
671 }
672 }
673 if(!contain) {
674 stk[p] = s[i];
675 dfs(stk, p + 1, cout, s);
676 }
677 }
678 }
void dfs(vector< vector< bool > > board, int current_row, vector< string > &ans, vector< int > &ans_stk)
Definition: acwing408.cpp:1003

引用了 acwing::acwing3472::dfs().

◆ main()

int acwing::acwing3429::main ( istream &  cin,
ostream &  cout 
)

在文件 acwing408.cpp680 行定义.

680 {
681 string s;
682 cin >> s;
683 vector<char> stk = vector<char>(s.length(), 0);
684 dfs(stk, 0, cout, s);
685 return 0;
686 }

引用了 acwing::acwing3472::dfs().

被这些函数引用 TEST().

◆ TEST()

acwing::acwing3429::TEST ( acwing3429  ,
case1   
)

在文件 acwing408_test.cpp1113 行定义.

1113 {
1114 istringstream in("abc");
1115 auto out = ostringstream();
1116 main(in, out);
1117 const auto ans = out.str();
1118 ASSERT_EQ("abc\n"
1119 "acb\n"
1120 "bac\n"
1121 "bca\n"
1122 "cab\n"
1123 "cba\n",
1124 ans);
1125 }
int main(int argc, char **argv)
Definition: main.cpp:5

引用了 main().