九度 题目1003:A+B

代码:

#include <sstream>
#include <string>
#include <iostream>

using namespace std;

inline int string_to_int(const string& str)
{
	int ret;
	stringstream ss;
	ss << str;
	ss >> ret;
	return ret;
}

inline string input_filter(const string& input)
{
	string ret;
	for (size_t i = 0; i < input.size(); ++ i)
	{
		if (input[i] != ',')
		{
			ret.push_back(input[i]);
		}
	}
	return ret;
}

int main()
{
	string a_input, b_input;

	while (cin >> a_input >> b_input)
	{
		int a = string_to_int( input_filter(a_input) );
		int b = string_to_int( input_filter(b_input) );
		cout << a + b << endl;
	}

	return 0;
}


你可能感兴趣的:(C++,九度,Jobdu)