PROFF - Professor Farouk Question
Professor farouk asked his students to create a variable of type integer and let it equal to 2147483647 then asked them to add 1 for this variable they found that the answer like that -2147483648 while it should be 2147483648. One of students said that we can use long and other said we can use Big Integer in java, but for sure professor farouk know all this things but he wanted to ask what will you do if there's no data type can have your result ?
one of sudents gave the best answer he said we can add multi-digit numbers from right-to-left one digit at a time and print the result. for sure by using this way he will find a carry for example
4+8=2 and carry 1
carry+2+6=9 carry 0
Your job is to create a program that count the number of carry operations.
Each line of input contains two unsigned integers less than 10 digits. The last line of input contains ‘0 0’.
For each line of input except the last you should compute and print the number of carry operations that would result from adding the two numbers, in the format shown below.
my 150th!!! first code C++ dont know what was wrong !! second wrote in C with similar approach...got AC :-)
do watch, for carry=1
Too much WA but finally done it
Please check my code, I really can't find the error... My submission id is 16362479
input format costed 3wa :(Last edit: 2016-01-12 17:02:23
@atef Can you check my solution? I have no idea what might be wrong with it, all test cases I can think of are fullfilledLast edit: 2016-01-02 17:42:25
for testcase 4898748546 5465456123
please check my solution..all possible cases i think are fulfilled