潇洒之人 @ 2022-10-07 10:56:08
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int a[2005],b[2005],c[2005];
int main(){
int la,lb,lc;
cin>>s1>>s2;
la=s1.length();
lb=s2.length();
for(int i=0;i<la;i++)a[la-i]=s1[i]-'0';
for(int i=0;i<lb;i++)b[lb-i]=s2[i]-'0';
lc=max(la,lb)+1;
for(int i=1;i<=lc;i++){
c[i]+=a[i]+b[i];
c[i+1]+=c[i]/10;
c[i]%=10;
}
if(c[lc]==0&&lc>0)lc--;
for(int i=lc;i>0;i--)cout<<c[i];
return 0;
}
五十分
by 3blue1blue @ 2022-10-07 10:57:53
有负数哦!(
by Failure_Terminator @ 2022-10-07 10:58:37
小 心 负 数
by InnitTimmer @ 2022-10-07 10:59:27
有负数!!
by 潇洒之人 @ 2022-10-07 11:06:11
@noiq @haimo @InnitTimmer 谢谢了
by lijiangxing @ 2022-10-12 10:21:53
不用高精度,用long long
by qianwanlang @ 2022-10-21 22:04:53
long long就可以
by Ctrl_Z @ 2022-10-25 18:08:43
@InnitTimmer 惊现机房大佬
by RayLiuLiu @ 2023-02-04 10:59:23
用
long long
就可以了 具体就是
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a+b;
return 0;
}