Problem Link:点击打开链接
题目描述
给定两个整数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
AC code:
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<map>
#include<math.h>
#include<string.h>
#include<queue>
#include<vector>
#include<set>
#define LL long long
#define exp 1e-9
#define MAXN 1000010
using namespace std;
LL sum(char str[])
{
LL s=0;
int fg,i;
if(str[0]=='-')
fg=-1;
else
fg=1;
if(fg==1)
s=str[0]-'0';
i=1;
while(str[i])
{
if(str[i]!=',')
s=s*10+(str[i]-'0');
++i;
}
return s*fg;
}
int main()
{
// freopen("D:\\in.txt","r",stdin);
char s1[111],s2[111];
LL a,b;
while(scanf("%s%s",&s1,&s2)!=EOF)
{
a=sum(s1);
b=sum(s2);
printf("%lld\n",a+b);
}
return 0;
}