c++

This is a discussion on c++ within the C++ Programming forums, part of the General Programming Boards category; Help me to program on with an input n, returns a list of all permutations of the numbers 1, 2, ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    3

    Question c++

    Help me to program on with an input n, returns a list of all permutations of the numbers 1, 2, ..., n. Use the fact that all permutations of 1, 2,..., n can be obtained from all the permutations of 1, 2, ..., n-1 by inserting n in all possible places.



    o this end, create a flat array having a size of n! * n. The array is just large enough to hold all permutations of size n, written contiguously into the array. For example, for n equals 3, the finished array could look like the following.


    1, 2, 3, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1 or
    3, 2, 1, 2, 3, 1, 2, 1, 3, 3, 1, 2, 1, 3, 2, 1, 2, 3

    Please help me

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Post your code and tell us where/what your problem is.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    reply

    Forum guidelines:
    Use a descriptive title (not just "C" or "C++"; make it specific). You don't need to write more than one H E L or P in help, and it definitely doesn't need to be capitalized.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Does anyone think this is another "do my homework for me" post.

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    homework

    Does anyone think this is another "do my homework for me" post.
    me thinks so....

    A passionate programmer asks questions of syntax and language capabilities rather than those of logic... logic is the fun part....
    zMan

  6. #6
    Budding Synth Programmer samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Trefforest
    Posts
    368
    Gotta agree with you there zMan.

    n! * n? That could be one chunky array, though!!!

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21