C语言:大数相乘.
发布时间:2020-12-14 03:29:02 所属栏目:大数据 来源:网络整理
导读:#includestdio.h#includestring.h#define N 200void mul(char a[],int n,char b[],int m){int s[N] = {0},i=N-1,p=0;int l,j;for( ; n=0; n--){for(j=i,l=m; l=0; j--,l--){s[j] = s[j] + (a[n]-'0')*(b[l]-'0')+p;p = s[j]/10;s[j] = s[j]%10;} while(p){ s
#include<stdio.h> #include<string.h> #define N 200 void mul(char a[],int n,char b[],int m) { int s[N] = {0},i=N-1,p=0; int l,j; for( ; n>=0; n--) { for(j=i,l=m; l>=0; j--,l--) { s[j] = s[j] + (a[n]-'0')*(b[l]-'0')+p; p = s[j]/10; s[j] = s[j]%10; } while(p) { s[j--] = p%10; p = p/10; } i--; } for(i=j+1; i<N; i++) printf("%d",s[i]); printf("n"); } int main() { char a[20],b[20]; int n,m; printf("nPlease input the first number: "); gets(a); n = strlen(a)-1; printf("nPlease input the second number: "); gets(b); m = strlen(b)-1; printf("nThe two numbers multibly is: "); mul(a,n,b,m); return 0; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- Lua函数的几种用法详解
- leetcode235 - Lowest Common Ancestor of a Bin
- vb.net – 单元测试框架NUNIT可以用于集成测试吗
- perl6 – 如何在Perl 6中的命令行上传递任意参数
- delphi – TIdCmdTCPServer和TIdCmdTCPClient应该
- 用协程手动控制基于Lua的两种框架:Codea和Love2D
- 大数据处理 — 浅析MapReduce之shuffle
- Delphi 与 DirectX 之 DelphiX(55): TDIB.DoMosa
- Delphi 调用 c编写的动态链接库,结构体指针作为
- delphi – 如何为尚不存在的节点显示虚拟树视图网
热点阅读