Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > STL & Generating exponents, permutations, arrangements, and combinations

Reply
Thread Tools

STL & Generating exponents, permutations, arrangements, and combinations

 
 
Alex Vinokur
Guest
Posts: n/a
 
      05-13-2004
Does STL contain algorithms which generate (enable to generate) exponents, permutations, arrangements, and combinations for any
numbers and words?

--
Alex Vinokur
(E-Mail Removed)
http://mathforum.org/library/view/10978.html





 
Reply With Quote
 
 
 
 
Tim Love
Guest
Posts: n/a
 
      05-13-2004
"Alex Vinokur" <(E-Mail Removed)> writes:

>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;
}


 
Reply With Quote
 
 
 
 
Alex Vinokur
Guest
Posts: n/a
 
      05-13-2004

"Tim Love" <(E-Mail Removed)> wrote in message news:c7vu3k$5hi$(E-Mail Removed)...
> "Alex Vinokur" <(E-Mail Removed)> writes:
>
> >Does STL contain algorithms which generate (enable to generate) exponents, permutations, arrangements, and combinations for any
> >numbers and words?

>
> exponents?
>

[snip]

See http://www.saliu.com/permutations.html
-------------------------------------------------
An example of exponents (N=3, M=3): 111,112,113,121,122,123,131,132, etc. (a total of 27 sets).
An example of permutations (for N = 3): 1 2 3, 1 3 2, 2 1 3, 2 3 1, 3 1 2, 3 2 1.
An example of arrangements (for N = 3, M = 2): 1 2, 1 3, 2 1, 2 3, 3 1, 3 2.
An example of combinations (for N = 3, M = 2): 1 2, 1 3, 2 3.
-------------------------------------------------

--
Alex Vinokur
(E-Mail Removed)
http://mathforum.org/library/view/10978.html



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating all combinations Johannes Bauer Python 22 06-05-2009 08:55 AM
Generating combinations mrajanikrishna@gmail.com ASP .Net 1 12-07-2006 09:57 PM
iterator? way of generating all possible combinations? akameswaran@gmail.com Python 16 05-31-2006 04:45 PM
Generating combinations from multiple sets Srinivas Jonnalagadda Ruby 1 01-16-2006 12:19 PM
Generating combinations pauljwilliams@lycosmax.co.uk C++ 4 09-08-2005 12:34 PM



Advertisments