Judgelight @ 2022-09-22 22:01:29
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 1009
using namespace std;
int x,y;
struct BigNumber{
int len,num[N];
};
BigNumber make(int n){
BigNumber big;
big.len=0;
while(n){
big.num[++big.len]=n%10;
n/=10;
}
return big;
}
BigNumber gjj(BigNumber a,BigNumber b){
int addnext=0;
BigNumber c;
c.len=0;
while(c.len<a.len||c.len<b.len){
c.num[++c.len]=a.num[c.len]+b.num[c.len]+addnext;
addnext=0;
if(c.num[c.len]>=10){
c.num[c.len]-=10;
addnext=1;
}
}
if(addnext){
c.num[++c.len]=addnext;
}
return c;
}
void Printf(BigNumber n){
for(int i=n.len;i>=1;i--){
cout<<n.num[i];
}
}
int main(){
cin>>x>>y;
Printf(gjj(make(x),make(y)));
return 0;
}
by CyaNgw_DyG @ 2022-09-22 22:20:37
Orz,这边建议看看题解
by Judgelight @ 2022-09-22 22:37:44
@CyaNgw_DyG
高精加都不会我可以退役了
stCo
by Ech0_7 @ 2022-09-22 23:02:35
其实,题解是个好东西
by CyaNgw_DyG @ 2022-09-23 12:49:29
@L_B_L Orz
by FanSizhe127 @ 2022-09-25 13:59:18
by Susara @ 2022-09-29 21:00:33
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a+b;
return 0;
}
这一题不需要高精度,正常int类型就行了,不需要高精度呀。
by tielusty @ 2022-10-05 13:03:07
@sutian 但凡问出这种问题的,多半是来整活的你发现没(
by LZL0317 @ 2022-10-05 21:49:11
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a+b;
return 0;
}
by CznTree @ 2022-10-08 20:37:23
@sutian 人家在整活 虽然我也是高精度过的
by Hughpig @ 2022-10-08 21:32:45
@L_B_L 负数