晨三娃


私信TA

用户名:13008142306

访问量:21014

签 名:

我的语言,没有对象

等  级
排  名 389
经  验 4962
参赛次数 6
文章发表 28
年  龄 20
在职情况 学生
学  校 西华大学
专  业 计算机科学与技术

  自我简介:

解题思路:





注意事项:





参考代码:

#include <iostream>

#include <deque>

#include <stack>

#include <queue>

#include <string>

#include <list>

using namespace std;

int main ()

{

string a,b;

while(cin>>a>>b){

stack<int,list<int> > s1,s2,res;

int len_a=a.length(),len_b=b.length();

for(int i=0;i<len_a;i++){

s1.push(a.at(i)-'0');

}

for(int i=0;i<len_b;i++){

s2.push(b.at(i)-'0');

}

int len=min(len_a,len_b),f=0;

for(int i=0;i<len;i++){

f+=s1.top()+s2.top();

s1.pop();

s2.pop();

res.push(f%10);

f/=10;

}

while(!s1.empty()){

f+=s1.top();

s1.pop();

res.push(f%10);

f/=10;

}

while(!s2.empty()){

f+=s2.top();

s2.pop();

res.push(f%10);

f/=10;

}

while(f){

res.push(f%10);

f/=10;

}

while(!res.empty()){

printf("%d",res.top());

res.pop();

}

printf("\n");

}

return 0;

}


 

0.0分

1 人评分

  评论区