What happens if I uncomment the commented line? Why are the outputs different?
using namespace std;
void permute_util (string s, int l, int r) {
if (l==r) cout << s << endl;
else {
for (int i=l;i<=r;i++) {
swap(s[l],s[i]);
permute_util(s,l+1,r);
// swap(s[l],s[i]);
}
}
}
void permute (string s) {
permute_util(s,0,s.length()-1);
}
int main() {
string s;
cin >> s;
permute(s);
return 0;
}