Show all the permutation...
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Show all the permutation...

  1. #1

    Talking Show all the permutation...

    Does anyone rember what an Permutation it is... for example if I got n=3 ...
    P(3)=3! .... that is not a problem for calculating that... the problem is that I would like to show/display all the posible combination...where n is from 1 .... to how long posible...

    Someting like this:


    If I got :
    n=1 ... to show 1
    n=2 ... to show 1,2 ; 2,1
    n=3 ... ti show 1,2,3 ; 1,3,2 ; 3,21; 3;1;2 ; 2,1,3; 2;3;1;
    .......
    Free PHP Scripts All kind of free and paid free php for your on-line business
    Free Online IQ Tests An cool mprove IQ your website
    Direct ISP Powerfull ISP Website For Sale
    Make Money On The Internet Tons of ways for making cash on the internet!
    iqbuster.com

  2. #2
    Join Date
    Apr 1999
    Posts
    27,424

    Re: Show all the permutation...

    Originally posted by lovelove
    ... the problem is that I would like to show/display all the posible combination
    A combination is not a permutation. A combination is related to a permutation, but is not the same thing.
    Code:
    #include <algorithm>
    #include <iostream>
    
    int main()
    {
       int array[] = {1,2,3 };
       std::cout << array[0] << " " << array[1] << " " << array[2] << std::endl;
       while (std::next_permutation(array, array + 3) )
           std::cout << array[0] << " " << array[1] << " " << array[2] << std::endl;
    }
    Regards,

    Paul McKenzie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center