How to create permutation of 3 letters based on string in C++

1 Answer

0 votes
#include <iostream>
#include <string>
#include <algorithm>

using std::cout;
using std::endl;
using std::string;

int main()
{
	string s = "abc";

	do	{
		cout << s << endl;
	} while (next_permutation(s.begin(), s.end()));

	cout << endl;

	return 0;
}


/*
run:

abc
acb
bac
bca
cab
cba

*/

 



answered May 19, 2018 by avibootz

Related questions

1 answer 179 views
1 answer 164 views
1 answer 168 views
1 answer 196 views
1 answer 198 views
1 answer 215 views
1 answer 151 views
...