标签:
clc; clear all; close all; A =‘962898798798798978987898‘; B = ‘9387978987987879899999999999999999999999999999999999999999999999999999999999999999‘; A = fliplr(A); B = fliplr(B); result=zeros(1,length(A)+length(B)); for i = 1:length(B) multiFlag =0; addFlag =0; for ii =1:length(A) temp1 = str2num(A(ii)) * str2num(B(i)) +multiFlag; multiFlag = floor(temp1/10); temp1 = mod(temp1,10); temp2 = result(i+ii-1)+ temp1+addFlag ; addFlag = floor(temp2/10); result(i+ii-1) = mod(temp2,10); end result(i+length(A)) = result(i+length(A))+multiFlag+addFlag; end ab = fliplr(result) ans = str2num(fliplr(A)) * str2num(fliplr(B))
标签:
原文地址:http://www.cnblogs.com/Kermit-Li/p/5386509.html