A correction:=0D
=0D
=0D
-------Original Message-------=0D
=0D
From: Ioannis Vranos=0D
Date: =D3=DC=E2=E2=E1=F4=EF, 15 =D6=E5=E2=F1=EF=F5=DC=F1=E9=EF=F2 2003 5:=
23:38 =F0=EC=0D
To: Dev-C++ Mailing List=0D
Subject: Nice combination algorithms=0D
=0D
I have been learning C++ for some time and here are 2 nice standard libra=
ry=20
algorithms for combinations. next_permutation() and =0D
=0D
=3D=3D>prev_permutation() defined in <algorithm>. Reference: TC++PL 3 on =
page
545, 18.10).=0D
=0D
=0D
And since they are generic they can be used with whatever kind of objects=
(e
g. .NET objects). An example:=0D
=0D
#include <iostream>=0D
#include <string>=0D
#include <algorithm>=0D
=0D
int main()=0D
{=0D
using namespace std;=0D
=0D
string s=3D"abcd";=0D
=0D
do=0D
cout<<s<<endl;=0D
while(next_permutation(s.begin(), s.end()));=0D
=0D
}=0D
=0D
Ioannis Vranos=0D
=0D
* Programming pages: http://www.noicys.freeurl.com=0D
* Alternative URL: http://run.to/noicys=20
|