首页 > 其他 > 详细

luogu_1601 A+B Problem(高精)

时间:2017-06-25 13:36:15      阅读:241      评论:0      收藏:0      [点我收藏+]

#include<bits/stdc++.h>
using namespace std;
string x,y;
int a[100],b[100];
void add(int a[],int b[]){
    for(int i=1;i<=max(a[0],b[0]);i++){
        a[i]+=b[i]; a[i+1]+=a[i]/10; a[i]%=10; if(a[0]<i)a[0]++;
    }
if(a[a[0]+1])a[0]++;
}
int main(){
    cin>>x>>y;
    a[0]=x.size(); b[0]=y.size();
    for(int i=0;i<a[0];i++)a[a[0]-i]=x[i]-‘0‘;
    for(int i=0;i<b[0];i++)b[b[0]-i]=y[i]-‘0‘;
    add(a,b);
    for(int i=a[0];i;i--)cout<<a[i];
    puts("");
    return 0;
}

luogu_1601 A+B Problem(高精)

原文:http://www.cnblogs.com/codetogether/p/7076593.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!