Artifact Content
Not logged in

Artifact 029a85274b27ccda289c953720891b01fd7e0dda



string add(const string& a, const string& b)
{
	int n = max(a.size(), b.size()), carry=0;
	string c(n, '0');
	for(int i=0; i<n; ++i) {
		int x = (a.size()<=i ? 0 : a[a.size()-1-i]-'0')
		      + (b.size()<=i ? 0 : b[b.size()-1-i]-'0') + carry;
		c[n-1-i] = char('0'+x%10);
		carry = x/10;
	}
	if( carry ) c = char('0'+carry)+c;
	return c;
}