Search:
Forum
UNIX/Linux Programming
Generate Permutations.
Generate Permutations.
Sep 26, 2008 at 12:04pm UTC
ashmew2
(7)
Hi , I want to Generate Permutations of 5 digit with numbers 1 to 6. How Can i go about it ? Im using G++ under Ubuntu Intrepid Ibex. Permutation is Basically Arrangement. like Using 1 , 2 and 3 , The possible permutations are :
123
132
213
231
312
321
Thanks.
Last edited on
Sep 26, 2008 at 12:13pm UTC
Sep 26, 2008 at 1:13pm UTC
jsmith
(5804)
Google next_permutation.
Sep 26, 2008 at 1:29pm UTC
ashmew2
(7)
Thanks jsmith , it looks promising!
Sep 26, 2008 at 1:38pm UTC
HaHai
(1)
#include <iostream>
using namespace std;
int main(){
int nb[] = {1,2,3};
for(int a=0; a<3; a++)
for(int b=0; b<3; b++)
for(int c=0; c<3; c++)
if(a!=b && a!=c && b!=c)
cout << nb[a] << nb[b] << nb[c] << endl;
return 0;
}
Sep 26, 2008 at 1:47pm UTC
ashmew2
(7)
Thankyou HaHai.
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs