string s = “bca”;
do {
cout << s << ’ ';
} while(next_permutation(s.begin(), s.end()));
cout << s;
What is the output of the given code?
string s = “bca”;
do {
cout << s << ’ ';
} while(next_permutation(s.begin(), s.end()));
cout << s;
What is the output of the given code?
Yes,but how it is printing abc at last?
while loop stop when next_permuatation will return false.
it return false when next lexicographical string is not possible and in that case it will return smallest string possible.
so in our case smallest string is abc.

thankyou so much
i got it!