解题思路:
注意事项:
参考代码:
#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 人评分
C语言训练-计算:t=1-1/(2*2)-1/(3*3)-...-1/(m*m) (C语言代码)浏览:798 |
矩阵乘法 (C++代码)浏览:1652 |
wu-理财计划 (C++代码)浏览:898 |
【求[X,Y]内被除3余1并且被除5余3的整数的和】 (C语言代码)浏览:703 |
用筛法求之N内的素数。 (C语言代码)浏览:709 |
钟神赛车 (C语言代码)浏览:662 |
C语言程序设计教程(第三版)课后习题12.6 (C语言代码)浏览:729 |
众数问题 (C语言代码)浏览:717 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:605 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:415 |