Description
Given two integers A and B, the expression is: each three digits are separated by commas.
Calculate the result of A + B and output it in the normal form.
Input
The input contains multiple groups of data. Each group occupies one row and consists of two integers A and B-10 ^ 9 <A, B <10 ^ 9 ).
Output
Calculate the result of A + B and output it as normal. Each group of data occupies one row.
Sample Input
-234,567,890 123,456,789
1,234 2,345,678
Sample Output
-111111101
2346912
The Code is as follows:
# Include <iostream>
# Include <string>
Using namespace std;
Int main ()
{
String a1, a2;
While (cin> a1> a2 ){
Int l1 = a1.size ();
Int l2 = a2.size ();
Int x1, x2;
X1 = x2 = 0;
Int f = 1;
For (int I = 0; I <l1; I ++)
{
If (a1 [I] = '-') {f =-1; continue ;}
If (a1 [I]! = ','){
X1 = x1 * 10 + a1 [I]-'0 ';
}
}
X1 = x1 * f;
F = 1;
For (int I = 0; I <l2; I ++ ){
If (a2 [I] = '-') {f =-1; continue ;}
If (a2 [I]! = ','){
X2 = x2 * 10 + a2 [I]-'0 ';
}
}
X2 = x2 * f;
Cout <x1 + x2 <endl;
}
// System ("pause ");
Return 0;
}