# Thread: help again

1. ## 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. How would you methodically generate all the combinations by hand?

3. Plan it out on paper like laserlight suggested. When you have the correct formular, ( use a calculator if it helps ) then write some puescode.

4. will u plz give me some example

5. No, we will not do your homework for you. Give it a try and post your non-working code.

6. 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...

7. 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.

8. *cough* combination, not permutation *cough*

9. So,
Code:
```#include <iostream>

using namespace std;

int main()
{
cout << "123" << endl;
cout << "132" << endl;
cout << "213" << endl;
cin.get();
return 0;
}```

10. > 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.

11. thanx frnd

12. 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