高精度_加法
来源:互联网 发布:政务大数据解决方案 编辑:程序博客网 时间:2024/06/05 04:26
#include<cstdio>#include<cstring>#include<iostream>using namespace std;void add(string s1,string s2){ char ch[1005];int l1=s1.length(),l2=s2.length(); int a[1005],b[1005],c[1005]; memset(a,0,sizeof(a));memset(b,0,sizeof(b));memset(c,0,sizeof(c)); for(int i=1;i<=l1;i++) a[i]=s1[l1-i]-'0'; for(int i=1;i<=l2;i++) b[i]=s2[l2-i]-'0'; c[0]=max(l1,l2); for(int i=1;i<=c[0];i++) c[i]=a[i]+b[i]; for(int i=1;i<=c[0];i++) if(c[i]>9) c[i]-=10,c[i+1]++; if(c[c[0]+1]>0) c[0]++; for(int i=1;i<=c[0];i++) ch[c[0]-i]=c[i]+'0'; printf("%s",ch);}int main(){ string a,b; cin>>a>>b; add(a,b);}
1 0
- 高精度_加法
- 高精度加法
- 高精度加法
- 高精度加法
- 高精度加法
- 高精度 加法
- 高精度加法
- 高精度加法
- 高精度加法
- 高精度加法
- 高精度加法
- 高精度加法
- 高精度加法
- 高精度加法
- 高精度加法
- 高精度加法
- 高精度加法
- 高精度加法
- Git相关
- [小笔记]Android 调节音乐音量大小&改变闹钟铃声大小
- 常用模块的测试用例(登录,添加,删除,查询)
- Julia: 引用、copy与数组
- Linux文件和目录常用命令
- 高精度_加法
- 网站开发进阶(八)tomcat异常日志分析及处理
- 如何使用multipart/form-data格式上传文件
- 原码, 反码, 补码 详解
- 支付宝的应用+代码
- 时间换算
- 第九周项目2- 对称矩阵压缩存储的实现与应用
- multithreading--演示中断线程Thread的异常
- 经典SQL语句大全