大数加法-Tsinsen A1087.高精度加法
来源:互联网 发布:access数据库实验心得 编辑:程序博客网 时间:2024/06/05 03:17
#include <cstdio>#include <iostream>#include <cmath>#include <algorithm>#include <string>#define maxSize 1000using namespace std;/*Tsinsen-A1087.高精度加法*/int main(){ string s; int a[101] = { 0 }, b[101] = { 0 }, c[102] = { 0 }; int maxLen, alen, blen, i, j = 0; cin >> s;//处理输入,字符转数字 reverse(s.begin(), s.end());//逆置 alen = s.size(); for (i = 0; i<alen; i++) a[i] = s[i] - 48; cin >> s; reverse(s.begin(), s.end());//逆置 blen = s.size(); for (i = 0; i < blen; i++) b[i] = s[i] - 48; maxLen = alen > blen ? alen : blen;//两数较大者的长度 for (i = 0; i < maxLen; i++) {//加法 c[i] = (a[i] + b[i] + j) % 10; //保存每一位运算结果 j = (a[i] + b[i] + j) / 10; //进位 } if (j)//最后还有进位 printf("%d", j); for (i = maxLen - 1; i >= 0; i--)//倒序输出 printf("%d", c[i]); cout << endl; return 0;}
0 0
- 大数加法-Tsinsen A1087.高精度加法
- A1087. 高精度加法
- 刷清橙OJ--A1087.高精度加法
- 高精度运算 大数加法
- 大数(高精度)加法
- 高精度大数加法
- 大数,高精度计算---大数加法
- 高精度--大数加法 luogu 1601
- 4、 大数,高精度计算---大数加法
- 大数加法 减法 乘法 除法 高精度四则运算
- 大数加法 减法 乘法 除法 高精度四则运算
- 高精度 大数加法 乘法 除法 幂 模板
- akoj-1218-高精度加法(大数问题)
- n个大数加法(高精度)
- 高精度 大数加法 乘法 除法 幂 模板
- 大数的加法和乘法,高精度
- 高精度加法——大数相加
- 高精度加法
- XMind中主题连接线格式修改教程
- WebRTC学习资料大全
- 面试:C++中static关键字的作用(转)
- ckeditor富文本编辑器的使用
- 线性表的链式存储结构
- 大数加法-Tsinsen A1087.高精度加法
- 优酷的订阅丢失解决方法
- python处理文本
- Java内存区域详解
- 1058. A+B in Hogwarts (20)
- 有趣的机器学习(七)
- 初探angularJS 二
- android 数据存储安全
- Java 8系列之默认方法