STL & Generating exponents, permutations, arrangements, and combinations

A

Alex Vinokur

Does STL contain algorithms which generate (enable to generate) exponents, permutations, arrangements, and combinations for any
numbers and words?
 
T

Tim Love

Alex Vinokur said:
Does STL contain algorithms which generate (enable to generate) exponents, permutations, arrangements, and combinations for any
numbers and words?

exponents?

Here's a quickie example of permutations that I had lying around. See the
doc for details.



#include <vector> //for vector
#include <functional> //for less
#include <iostream>
using namespace std;
int main()
{
char a2[] = "abcdefghij";
vector<char> m2(a2, a2+10);
vector<char> next_m2((size_t)10);

next_m2=m2;
next_permutation(next_m2.begin(),
next_m2.end(),less<int>());

cout << "Original values: ";
copy(m2.begin(),m2.end(),
ostream_iterator<char>(cout," "));
cout << endl;

cout << "Next Permutation: ";
copy(next_m2.begin(),next_m2.end(),
ostream_iterator<char>(cout," "));
cout << endl << endl;

return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top