来源:程军康|编辑日期:2009-11-06 10:27:06|点击数: |发布:55
高精度乘法和阶乘
一、高精度乘法基本思想和加法一样。其基本流程如下:
①读入被乘数s1,乘数s2 |
②把s1、s2分成4位一段,转成数值存在数组a,b中;记下a,b的长度k1,k2; |
③i赋为b中的最低位; |
④从b中取出第i位与a相乘,累加到另一数组c中;(注意:累加时错开的位数应是多少位?) |
⑤i:=i-1;检测i值:小于k2则转⑥,否则转④ |
⑥打印结果 |
例:程序下载
program chengfa;
const n=100;
type ar=array [1..n] of integer;
var a,b:ar; k1,k2,k:integer;
c:array [1..200] of integer;
上一篇:
下一篇: