Thread: help again

  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
    28,413
    How would you methodically generate all the combinations by hand?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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,688
    Plan it out on paper like laserlight suggested. When you have the correct formular, ( use a calculator if it helps ) then write some puescode.
    Double Helix STL

  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
    28,413
    *cough* combination, not permutation *cough*
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > 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.

  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,318
    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