测试用例位数比较低,可以直接转成int型进行计算。

#include <iostream>
#include <cstring> 
#include <algorithm>
#include <math.h>
#include <string.h> 
#include <stdlib.h>
using namespace std;
#define N 81
int main(){
	char a[N],b[N];	//存字符串
	
	while(cin >> a >> b){
		int aa = 0,bb = 0;//将字符串转成整数存入
		int i = 0,j = 0;
		int flag = 1;//正负数标志位
		//存aa
		while (a[i] != '\0'){
			if (a[i] == '-') flag = -1;
			else if (a[i] !=',') aa = aa*10 + a[i]-'0';
			i++;
		}
		aa *= flag;
		//存bb
		flag = 1;
		while (b[j]!='\0'){
			if (b[j] == '-') flag = -1;
			else if (b[j] !=',') bb = bb*10 + b[j]-'0';
			j++;
		}
		bb *= flag;

		cout <<aa+bb<<endl;
	
	}


	
}