求助本地全过但洛谷全WA
查看原帖
求助本地全过但洛谷全WA
1147003
hi_hi_hi楼主2024/1/12 20:46
#include<bits/stdc++.h>
using namespace std;
int main() {
	stack<int> a;
	stack<int> b;
	queue<int> s;
	stack<int> ss;
	char c;
	while((c=getchar())!='\n') {
		a.push(c-'0');
	}
	while((c=getchar())!='\n'&&c!=EOF) {
		b.push(c-'0');
	}
	while(!(a.empty()||b.empty())) {
		s.push(a.top()+b.top());
		a.pop();
		b.pop();
	}
	if(!(a.empty()&&b.empty())) {
		if(a.empty()) {
			s.push(b.top());
			b.pop();
		} else if(b.empty()) {
			s.push(a.top());
			a.pop();
		}
	}
	s.push(0);
	while(!s.empty()) {
		int i=s.front();
		ss.push(i%10);
		s.pop();
		s.front()+=i/10;
	}
	if(ss.top()==0)ss.pop();
	while(!ss.empty()) {
		printf("%1d",ss.top());
		ss.pop();
	}
	return 0;
}
2024/1/12 20:46
加载中...