Question Analysis:
Use the and B strings to store the two groups of input data. First, remove the non-numeric symbols and obtain the value of the number. Then determine the plus and minus signs. If there is a negative number, it is in the beginning of the string. After the judgment, the data value is obtained for calculation.
Source code:
[Cpp]
# Include <iostream>
# Include <string>
Using namespace std;
Int main ()
{
String A, B;
While (cin> A> B)
{
Long m = 0, n = 0;
For (int I = 0; I <A. length (); I ++)
{
If (A [I]> = '0' & A [I] <= '9 ')
{
// Obtain the value corresponding to the character
M = m * 10 + A [I]-'0 ';
}
}
For (int I = 0; I <B. length (); I ++)
{
If (B [I]> = '0' & B [I] <= '9 ')
{
// Obtain the value corresponding to the character
N = n * 10 + B [I]-'0 ';
}
}
If (A [0] = '-')
{
M = 0-m;
}
If (B [0] = '-')
{
N = 0-n;
}
Cout <m + n <endl;
}
Return 0;
}
# Include <iostream>
# Include <string>
Using namespace std;
Int main ()
{
String A, B;
While (cin> A> B)
{
Long m = 0, n = 0;
For (int I = 0; I <A. length (); I ++)
{
If (A [I]> = '0' & A [I] <= '9 ')
{
// Obtain the value corresponding to the character
M = m * 10 + A [I]-'0 ';
}
}
For (int I = 0; I <B. length (); I ++)
{
If (B [I]> = '0' & B [I] <= '9 ')
{
// Obtain the value corresponding to the character
N = n * 10 + B [I]-'0 ';
}
}
If (A [0] = '-')
{
M = 0-m;
}
If (B [0] = '-')
{
N = 0-n;
}
Cout <m + n <endl;
}
Return 0;
}