Thread: N possibilities

  1. #1
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683

    N possibilities

    I have a problem solving a proble...

    I wopuld great full to any one who can provide me with the algorithm and tips to solve ths..

    Conside that a user enters n numbers example(2,56 ,51 ,6,1,2,3,4,5,6) etc etc.. Well i want the program to find all the possible combination using the given numbers. If there are 2 numbers 1 and 2 and 3 then possibiliies such as 12,13,123,21,23,213,31,3,1,2,321,123 etc etc can be formed.. I want this to work for N numbers.. please help me...

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    I think factorials is what you need. n!
    Dunno if that is provided in any header, its fairly easy to write though...n! is the number of permutations of n items. I'll leave it up to you as an exercise to find. Man I sound like my math teacher.
    Last edited by MrWizard; 04-07-2002 at 11:17 PM.

  3. #3
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    Ex: 5! = 5*4*3*2*1 = 120
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  4. #4
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    This thread will probably help you out..

    http://www.cprogramming.com/cboard/s...threadid=12703
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  5. #5
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    I think i need more help..

  6. #6
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    The code silentstrike proposed is almost exactly what you need. Take another look.

  7. #7
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    Ok i will see..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. split number (all possibilities)
    By l2u in forum C Programming
    Replies: 3
    Last Post: 04-13-2008, 11:44 AM
  2. Console Window Possibilities.....
    By dac in forum C++ Programming
    Replies: 3
    Last Post: 10-22-2006, 05:01 AM
  3. real random numbers
    By mewatC in forum C Programming
    Replies: 7
    Last Post: 09-01-2006, 01:39 PM
  4. Help with AI possibilities
    By Syneris in forum General AI Programming
    Replies: 2
    Last Post: 01-01-2006, 02:52 AM
  5. Regarding Job Possibilities as a C/C++ programmer on a Linux Platform
    By pritesh in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-22-2002, 09:26 AM