课堂原代码,码风规范,简洁易懂
2025-07-31 17:59:42
发布于:上海
5阅读
0回复
0点赞
#include<iostream>
using namespace std;
string s, t;
int a[10001], b[10001], c[10002];
int main(){
cin >> s >> t;
int lens = s.size();
int lent = t.size();
for(int i = 0; i < lens; i++){
a[i] = s[lens - i - 1] - '0';
}
for(int i = 0; i < lent; i++){
b[i] = t[lent - i - 1] - '0';
}
int len = max(lens, lent);
for(int i = 0; i < len; i++){
c[i] += a[i] + b[i];
if(c[i] >= 10){
c[i] -= 10;
c[i + 1]++;
}
}
if(c[len]){
len++;
}
for(int i = len - 1; i >= 0; i--){
cout << c[i];
}
return 0;
}
全部评论 2
觉得作者码风看着舒适的,建议来此团交流学习:戳我开启高效学习之旅
2天前 来自 上海
0制作不易,留赞后去
2天前 来自 上海
0
有帮助,赞一个