I have a file that contains numbers in ascending form(max 2 digit) in a line in sorted form with no separation.
123111517224547
Now what i want to do is to read the number and display it on the console.
for this example the output will be
1 2 3 11 15 17 22 45 47
Now how can i do that since i have no delimiter ?
4 replies to this topic
#1
Posted 23 June 2011 - 07:44 PM
|
|
|
#2
Posted 23 June 2011 - 08:49 PM
Keep track of the size of the numbers, and the previous number's first digit. This will not always work though. Consider the two sets:
1 2 3
1 23
There is no way to distinguish other than by heuristics.
1 2 3
1 23
There is no way to distinguish other than by heuristics.
#3
Posted 23 June 2011 - 10:51 PM
yea the main problem with this is to find the point where the two digit number starts , I have made a logic and coded it that the program checks
if the 1st digit is 1 then save it , when the next 1 comes then naturally two digit number will start .
But the problem with this is that if there is no 1digit number then how will the program cater this problem.
if the 1st digit is 1 then save it , when the next 1 comes then naturally two digit number will start .
But the problem with this is that if there is no 1digit number then how will the program cater this problem.
#4
Posted 23 June 2011 - 11:22 PM
What if the numbers were
1234567890
1 < 2 < 3 < 4 < .. < 9
12 < 34 < 56 < 78 < 90
1 < 2 < 34 < 56 < 78 < 90
1 < 2 < 3 < 4 < 56 < 78 < 90
etc.
This leaves many possibly solutions.
1234567890
1 < 2 < 3 < 4 < .. < 9
12 < 34 < 56 < 78 < 90
1 < 2 < 34 < 56 < 78 < 90
1 < 2 < 3 < 4 < 56 < 78 < 90
etc.
This leaves many possibly solutions.
#5
Posted 24 June 2011 - 03:33 PM
I have solved the problem . The numbers = always 20 so it was easy to check , that if there is no 1 digit number the length of string will be 40 , and so on .
Thanks for the replies :)
Thanks for the replies :)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









