Question 74
Question information running result this question ranking discussion area pupils Arithmetic
Time Limit: 3000 MS | memory limit: 65535 KB
Difficulty: 1
Description
When learning addition, many pupils find that "carry" is particularly prone to errors. Your task is to calculate the number of carry-places required for adding two three-digit numbers. Your program should be able to process multiple groups of data continuously until two zeros are read (this is the end mark of input ).
Input
Input two positive integers m, n. (m, n, all three digits)
Output
Output M, N. How many times do I have to carry when I add them.
Sample Input
123 456
555 555
123 594
0 0 sample output
0
3
1
# Include <iostream>
Using namespace STD;
Int main ()
{
Int m, n, I, J, K;
While (CIN> m> n, m | N) // while (CIN> m> N, M & N)
{
If (M> = 100 & M <1000) & (n> = 100 & n <1000 ))
If (M % 10 + N % 10> = 10) I = 1; else I = 0; // bit
If (M/10% 10 + N/10% 10 + I> = 10) j = 1; else J = 0; // ten ·
If (M/100% 10 + N/100% 10 + j> = 10) k = 1; else K = 0; // hundreds of digits ·
Cout <I + J + k <Endl;
}
}
***************************
**************************************
# Include <iostream>
Using namespace STD;
Int main ()
{
Int m, n, I, J, K;
While (CIN> m> N)
{
If (M> = 100 & M <1000) & (n> = 100 & n <1000 ))
If (M % 10 + N % 10> = 10) I = 1; else I = 0; // bit
If (M/10% 10 + N/10% 10> = 10) j = 1; else J = 0; // ten ·
If (M/100% 10 + N/100% 10> = 10) k = 1; else K = 0; // hundreds of digits ·
Cout <I + J + k <Endl;
}
}
***********
Error
**********************
# Include <iostream>
Using namespace STD;
Int main ()
{
Int m, n, I, J, K;
While (CIN> m> n, m | N)
{
If (M> = 100 & M <1000) & (n> = 100 & n <1000 ))
If (M % 10 + N % 10> = 10) I = 1; else I = 0; // bit
If (M/10% 10 + N/10% 10> = 10) j = 1; else J = 0; // ten ·
If (M/100% 10 + N/100% 10> = 10) k = 1; else K = 0; // hundreds of digits ·
Cout <I + J + k <Endl;
}
}
**************************************** ***********************
# Include <iostream>
Using namespace STD;
Int main ()
{Int A, B;
While (CIN> A> B)
{
Int S = 0;
If (A = 0 & B = 0) break;
If (a % 10 + B % 10 >=10) {s ++ ;}
If (a % 10 + B % 10> = 10) & (A/10% 10 + B/10% 10 + 1)> = 10 )) {s ++ ;}
If (A/10% 10 + B/10% 10)> = 10 | (a % 10 + B % 10> = 10 & (A/10% 10 + B/10% 10 + 1> = 10 ))) {s ++ ;}
Cout <S <Endl;
}
}
****************************
# Include <stdio. h>
Int main ()
{
Int m, n, I, J, K;
While (scanf ("% d", & M, & N) & M! = 0 & n! = 0)
{
If (M> 100 & M <1000 & n> 100 & n <1000)
{
If (M % 10 + N % 10)> = 10) I = 1; else I = 0;
If (M/10% 10 + N/10% 10 + I)> = 10) j = 1; else J = 0;
If (M/100 + N/100 + J)> = 10) k = 1; else K = 0;
}
Printf ("% d \ n", I + J + k );
}
}
++ ++
# Include <stdio. h>
Int main ()
{
Int m, n, I, J, K;
While (scanf ("% d", & M, & N) & M! = 0 & n! = 0)
{
If (M> 100 & M <1000 & n> 100 & n <1000)
If (M % 10 + N % 10)> = 10) I = 1; else I = 0;
If (M/10% 10 + N/10% 10 + I)> = 10) j = 1; else J = 0;
If (M/100 + N/100 + J)> = 10) k = 1; else K = 0;
Printf ("% d \ n", I + J + k );
}
}