??? 11/06/09 12:09 Read: times |
#170494 - Have you written the code? Responding to: ???'s previous message |
You are saying "moving", but it seems that your code isn't moving any digits. Instead, you are adding 1111 to the number. If you constantly add 1111, then you must (for each of the four digits) catch the overflow after 9 and restart that digit position from zero.
An alternative is that you really do move the values left. Then you only need to keep track of the single digit that should be inserted at the rightmost position. But same thing there. If an increment results in a value larger than 9, then set it to zero. But why are you asking? If you have written the code, then it would be reasonable that you do know what the different parts of the code does, and don't have to ask us where to insert code to handle the overflow/turn-around. Always makes sure that you understand your code. Never turn in any code (yours or "found") that you don't understand completely so that you can explain to the teacher each step of the code. Understanding your own code is a minimum requirement to be able to debug the code. Or to extend it. Or to be able to take the experiences from one project and make the next project one step better. |