Hi To Everyone!
I want to help me in the followin subject:
Suppose that you have the numbers:
400,20,6,50,2 stored in an array. If you want to get out of this a seven digit number (in a string format) (eliminating some zeros - and olny zeros) you will get: either 4002652 or 4206502, 4020652 and maybe others. Can you give a sample code of how Am I going to produce these results? I always want a seven digit result, I don't want the initial numbers to change their position, and the Input of the user (initial numbers) that is stored in an array is not of a standard format.
Than U in advance!!!
Comments
: I want to help me in the followin subject:
: Suppose that you have the numbers:
: 400,20,6,50,2 stored in an array. If you want to get out of this a seven digit number (in a string format) (eliminating some zeros - and olny zeros) you will get: either 4002652 or 4206502, 4020652 and maybe others. Can you give a sample code of how Am I going to produce these results? I always want a seven digit result, I don't want the initial numbers to change their position, and the Input of the user (initial numbers) that is stored in an array is not of a standard format.
: Than U in advance!!!
:
I would probably create a second array of approx 30 characters i length. Then seperate each number into each digit and store it into the new array. for Ex:
[code]
VAR
IndDigits : Array[1..30] Of Char;
[/code]
And IndDigits would contain (with your example):
[code]
'4','0','0','2','0','6','5','0','2','','',...
[/code]
Now, run through and count how many numbers are not zeros (in this case five). If more than seven numbers are non-zero, then the program cannot make a seven digit number without dropping a non-zero number.
Once that is done, then you can just go through and make each number inside of a loop.
Phat Nat