题目描述
给定两个整数A和B,其表示形式是:从个位开始,每三位数用逗号","隔开。
现在请计算A+B的结果,并以正常形式输出。
输入
输入包含多组数据数据,每组数据占一行,由两个整数A和B组成(-10^9 < A,B < 10^9)。
输出
请计算A+B的结果,并以正常形式输出,每组数据占一行。
样例输入
-234,567,890 123,456,789
1,234 2,345,678
样例输出
-111111101
2346912
#include <cstdio>
#include <iostream>
#include <string.h>
using namespace std;
//把字符串转化为整数的函数
void stoi(char s[], long long int &x)
{
int len = strlen(s);
//对字符串处理 转化为整数
for(int i=0; i<len;i++)
{
if(s[i] >= '0' && s[i]<='9' )
x = x*10 + s[i]-'0';
}
//对负号处理
if(s[0] == '-')
x = -x;
}
int main()
{
char s1[100],s2[100];
int len1,len2;
long long int a,b;
while(scanf("%s%s",s1,s2) != EOF)
{
a = b = 0;
stoi(s1,a);
stoi(s2,b);
cout<<a+b<<endl;
}
return 0;
}