博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
大数加法和乘法
阅读量:7071 次
发布时间:2019-06-28

本文共 747 字,大约阅读时间需要 2 分钟。

#include
#include
#include
const int Len=5000//大数的长度using namespace std;int Input (char n[])//将大数读入的函数{ char s[Len]; int l; for(int i=0; i
0; i--) if(n[i]!=0) break; for(; i>=0; i--) printf("%d",n[i]); printf("\n");}void Add (char a[],char b[],char c[])//大数加法{ int i=0; for(i=0; i
=10) { c[i+1]+=c[i]/10; c[i]=c[i]%10; } }}void Mul(char a[],char b[],char c[])//大数乘法{ int i,j; int alen=strlen(a),blen=strlen(b); for(i=0; i
=10) { c[i+j+1]+=c[i+j]/10; c[i+j]%=10; } }}int main(){ char a[Len],b[Len],c[Len]; Input(a); Input(b); Add(a,b,c); Print(c); Mul(a,b,c); Print(c); return 0;}

转载地址:http://zeell.baihongyu.com/

你可能感兴趣的文章
Linode CentOS 7 使用 Mina 部署 Rails API 项目 Postgresql 9.6 + Nginx + Puma + Rbenv
查看>>
git下载仓库指定目录
查看>>
AVL树
查看>>
ios 笔记
查看>>
十六、类的真正形态
查看>>
laravel中Dingo api如何Custom ExceptionHandler
查看>>
前端_JavaScript_API
查看>>
LeetCode 310. Minimum Height Trees
查看>>
mysql-存储过程
查看>>
PAT A1122
查看>>
Callbacks, Promises and Async/Await
查看>>
全链路压测自动化实践
查看>>
软件测试行业年度核心热点数据大揭秘(2018 )
查看>>
Vagrant (四) - Box 的用法
查看>>
前端代码风格自动化系列(四)之Prettier
查看>>
访问者模式
查看>>
Go routine调度
查看>>
Python 二分查找与 bisect 模块
查看>>
webpack4系列教程(十):总结
查看>>
【性能优化】quicklink:实现原理与给前端的启发
查看>>