社区讨论
第三和第五个样例没过
P1601高精度加法参与者 4已保存回复 7
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 7 条
- 当前快照
- 1 份
- 快照标识符
- @m0debugl
- 此快照首次捕获于
- 2024/08/28 13:08 2 年前
- 此快照最后确认于
- 2025/11/04 22:12 4 个月前
CPP
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
char a[505],b[505];
int x,y,cnt(0),f[505],tmp(0),hhh(0);
int main(){
cin>>a>>b;
x=strlen(a);
y=strlen(b);
while(x>0||y>0){
int zz=((a[x-1]-'0')+(b[y-1]-'0')+cnt);
if(zz<10){
f[tmp]=zz;
tmp++;
cnt=0;
}else{
f[tmp]=zz-10;
tmp++;
cnt=1;
}
x--;y--;
}
if(f[tmp]==0){
cout<<1;
}
for(int i=tmp-1;i>=0;i--){
cout<<f[i];
}
return 0;
}
似乎遇到特别大的数过不去,烦请解答
回复
共 7 条回复,欢迎继续交流。
正在加载回复...