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

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

大数乘

Time Limit:5000MS  Memory Limit:32768K

Description:

给定一些大数,请计算其积。

Input:

输入数据中含有一些整数对(对数≤1000),若某对整数(整数位数≤200)的值为0 0,则表示输入结束。

Output:

每对整数对应一个乘法计算结果,输出该结果,每个结果输出完后应回车。

Sample Input:

2 312 340 0

Sample Output:

6408
1 /* 功能Function Description:     大数相乘 2    开发环境Environment:          DEV C++ 4.9.9.1 3    技术特点Technique: 4    版本Version: 5    作者Author:                   可笑痴狂 6    日期Date:                     20120725 7    备注Notes: 8 */ 9 #include
10 #include
11 #define MAX 21012 13 int main()14 {15 char s1[MAX],s2[MAX];16 int i,j,len1,len2;17 int a[MAX],b[MAX],res[MAX*2];18 while(scanf("%s%s",s1,s2))19 {20 memset(res,0,sizeof(res));21 if(strcmp(s1,"0")==0&&strcmp(s2,"0")==0)22 break;23 len1=strlen(s1);24 len2=strlen(s2);25 for(i=len1-1,j=0;i>=0;--i)26 a[j++]=s1[i]-'0';27 for(i=len2-1,j=0;i>=0;--i)28 b[j++]=s2[i]-'0';29 for(i=0;i
=10)35 {36 res[i+1]+=res[i]/10;37 res[i]%=10;38 }39 }40 while(i>=0&&res[i]==0)41 --i;42 if(i>=0)43 {44 for(;i>=0;--i)45 printf("%d",res[i]);46 printf("\n");47 }48 else49 printf("0\n");50 }51 return 0;52 }

 

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

你可能感兴趣的文章
Vue 爬坑之路(九)—— 用正确的姿势封装组件
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
兼容ie6/ie7的inline-block元素的两端对齐布局
查看>>
我的友情链接
查看>>
忘记root密码通过单用户模式重置过程
查看>>
【解决】Starting httpd: httpd: apr_sockaddr_info_get() failed for DB2
查看>>
Google开源网页加速工具Page Speed
查看>>
shell脚本的一些注意事项
查看>>
结构体
查看>>
GNS模拟器完全使用图文指南
查看>>
人生=亲情+爱情+金钱+理想+友情?
查看>>
VUE devtools 调试工具安装 让vue飞起来
查看>>
LNMP之memcached实现tomcat群集(三)
查看>>
我的友情链接
查看>>
Android IPC进程间通讯机制
查看>>
无损音乐资源
查看>>
对SpringAop的思考之基于cglib的动态代理
查看>>
Linux5.3双网卡绑定虚拟成一块网卡
查看>>
轻松获取格林尼治Linux时间戳
查看>>