help again

This is a discussion on help again within the C++ Programming forums, part of the General Programming Boards category; well friends i have to write a program which generates all combination of 1,2,3, plz give me some hints coz ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    35

    help again

    well friends i have to write a program which generates all combination of 1,2,3, plz give me some hints coz i have to submit it 17th jan

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,598
    How would you methodically generate all the combinations by hand?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475
    Plan it out on paper like laserlight suggested. When you have the correct formular, ( use a calculator if it helps ) then write some puescode.
    I'm just trying to be a better person - My Name Is Earl

  4. #4
    Registered User
    Join Date
    Jan 2007
    Posts
    35
    will u plz give me some example

  5. #5
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    No, we will not do your homework for you. Give it a try and post your non-working code.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  6. #6
    For Narnia! Sentral's Avatar
    Join Date
    May 2005
    Location
    Narnia
    Posts
    719
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
           cout << "123" << endl;
           cout << "132" << endl;
           cout << "321" << endl;
           cout << "312" << endl;
           cout << "213" << endl;
           cout << "231" << endl;
           
           return 0;
    }
    lol...
    Videogame Memories!
    A site dedicated to keeping videogame memories alive!

    http://www.videogamememories.com/
    Share your experiences with us now!

    "We will game forever!"

  7. #7
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    Quote Originally Posted by Sentral
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
           cout << "123" << endl;
           cout << "132" << endl;
           cout << "321" << endl;
           cout << "312" << endl;
           cout << "213" << endl;
           cout << "231" << endl;
           
           return 0;
    }
    lol...
    Yup, the manual way is the best way.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,598
    *cough* combination, not permutation *cough*
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    So,
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
           cout << "123" << endl;
           cout << "132" << endl;
           cout << "213" << endl;
           cin.get();
           return 0;
    }
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    > plz give me some hints
    Well do what laserlight suggested.

    Like 123 is
    1 + all combinations of 23
    2 + all combinations of 13
    3 + all combinations of 12

    Rinse and repeat with some recursion - should be pretty obvious.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  11. #11
    Registered User
    Join Date
    Jan 2007
    Posts
    35
    thanx frnd

  12. #12
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,299
    Quote Originally Posted by laserlight
    *cough* combination, not permutation *cough*
    Which would mean an answer would be more like this:
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
           cout << "" << endl;
           cout << "1" << endl;
           cout << "2" << endl;
           cout << "3" << endl;
           cout << "12" << endl;
           cout << "13" << endl;
           cout << "23" << endl;
           cout << "123" << endl;
    }
    Of course I doubt he actually meant combination, as he didn't state how many items to pick, only what to pick from.

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