Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by minhkhanh ( 5 years ago )
#include<iostream>
#include<string>
using namespace std;
void hoanvi(string& s, int k, int n) {
if (k == n)cout << s<<" " <<endl;
else {
for (int i = k; i < n; i++) {
swap(s[k], s[i]);
hoanvi(s,k+1,n);
swap(s[k], s[i]);
}
}
}
int main() {
string str= "ABCDE";
int n = str.size();
hoanvi(str, 0, n-1);
return 0;
}
Revise this Paste