文章

227

粉丝

0

获赞

1000

访问

38.3k

头像
大整数加法 题解:
P1474 武汉大学机试题
发布于2026年2月4日 23:04
阅读数 106

#include<iostream>
using namespace std;

string a,b;

void work()
{
	int t=0;
	for(int i=a.size()-1;i>=0;i--)
	{
		int x=a[i]-'0';
		int y=b[i]-'0';
		int res=x+y+t;
		t=res/10;
		res=res%10;
		a[i]='0'+res;
	}
	if(t==1)
	cout<<t;
	cout<<a<<endl;
}

int main()
{
	while(cin>>a>>b)
		work();
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发