抽风了,居然40分
查看原帖
抽风了,居然40分
1066396
szm111213楼主2024/12/27 15:36
#include<bits/stdc++.h>
using namespace std;
int stoii(char s)
{
	return s - '0';
}
string jia(string a, string b)
{
	string ans = "";
	if(a.size() > b.size())
	{
		swap(a, b);
	}
	if(a.size() < b.size())
	{
		while(a.size() < b.size())
		{
			a = "0" + a;
		}
	}
	int jw = 0;
	for(int i = a.size() - 1; i >= 0; i --)
	{
		int z = stoii(a[i]) + stoii(b[i]);
		int w = z;
		if(z > 10)
		{
			w = z - 10;
		}
		ans = to_string(w + jw) + ans;
		if(z > 10)
		{
			jw = z - 10;
		}
	}
	return ans;
}
int main()
{
	string a, b;
	cin >> a >> b;
	cout << jia(a, b) << endl;
	return 0;
}

2024/12/27 15:36
加载中...