0

Help me about simple code

I have a problem: I should create a program that allows to choose a number (with a quantity of digits greater than two but less than seven) and to output all the possible pair combinations between the various digits but without repetitions. The only thing I know is this kind of scheme: State variables Put cin Break the number down into numbers Put them in an array Cycle for another array with pairs Cout array but I do not know how to turn it into code.

21st May 2018, 9:12 AM
Amerigo
4 Respostas
0
This can be do in multiple way but at basic you can: 1) get your number in array form for easy processing Hint: you can use module operator for get how many digits has your number if you have need 2) Because your code dont allow repetitions you have to to make sure that dont more than 1 time an digit is repeated in array used for processing... example: int number= 1822342; your array must filled like: // note that 2 is present only one time in to process array int array[]= {1,8,2,3,4}; 3) If you must print same-digit number (example 22) you must handle it by creating another array filled with repeated digit... Example: int number= 1823234; int array[]= {1,8,2,3,4}; int repeated[]= {2,3}; This help you to write digit-repeted number (22 and 33 in this case)
21st May 2018, 9:53 AM
KrOW
KrOW - avatar
0
I try first with this code, but my prof say that it s wrong https://code.sololearn.com/cKJAo663bm43/?ref=app
21st May 2018, 9:13 AM
Amerigo
0
And now I start with this code but i don t know how to proceed https://code.sololearn.com/cWvN8ectwZO1/?ref=app
21st May 2018, 9:14 AM
Amerigo
0
Maybe he meant that the outcomes should contain all possible non repeated combinations and not only pairs? like in your code, there could also be- 345, 3456, 34567 ?
21st May 2018, 9:36 AM
Sachin Artani
Sachin Artani - avatar