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
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 ...
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
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
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
will u plz give me some example
No, we will not do your homework for you. Give it a try and post your non-working code.
lol...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; }
Videogame Memories!
A site dedicated to keeping videogame memories alive!
http://www.videogamememories.com/
Share your experiences with us now!
"We will game forever!"
Yup, the manual way is the best way.Originally Posted by Sentral
![]()
![]()
![]()
ERROR: Brain not found. Please insert a new brain!
“Do nothing which is of no use.” - Miyamoto Musashi.
*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
So,Code:#include <iostream> using namespace std; int main() { cout << "123" << endl; cout << "132" << endl; cout << "213" << endl; cin.get(); return 0; }
> 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.
thanx frnd
Which would mean an answer would be more like this:Originally Posted by laserlight
Of course I doubt he actually meant combination, as he didn't state how many items to pick, only what to pick from.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; }