class BigMultiply:BigCalculate
{
public override string Oper(string num1, string num2)
{
if (num1.Equals("0")||num2.Equals("0"))
{
return "0";
}
List liAllNum = new List();//存储乘数每位乘法的结果
List liCh = new List();//存储乘数每位乘法中每一位的结果
//将长度较长的数字赋给num1,方便后面计算
if (num1.Length < num2.Length)
{
ChangeNum(ref num1, ref num2);
}
int flag;
for (int i = num2.Length-1; i >=0; i--)
{
//初始化上一位乘法中的数据
liCh.Clear();
flag = 0;
//计算第i位乘以第j位
for (int j = num1.Length - 1; j >= 0; j--)
{
liCh.Add((char)((num2[i] - '0') * (num1[j] - '0')+flag+'0'));
flag = (liCh[liCh.Count-1] -'0')/ 10;
liCh[liCh.Count - 1] = (char)((liCh[liCh.Count - 1] - '0') % 10+'0');
}
//若进位不为0,则在加进位
if (flag>0)
{
liCh.Add((char)(flag+'0'));
}
//添加结果集
liAllNum.Add(InvertOrder(new string(liCh.ToArray()))+new string('0',liAllNum.Count));
}
int count = 0;
string res="0";
//调用add方法,将每一位乘法所得的结果相加,即为结果
BigAdd addOper= new BigAdd();
while (count
{
res = addOper.Oper(res,liAllNum[count]);
count++;
}
return res;
}
}
public override string Oper(string num1, string num2)
{
if (num1.Equals("0")||num2.Equals("0"))
{
return "0";
}
List liAllNum = new List();//存储乘数每位乘法的结果
List liCh = new List();//存储乘数每位乘法中每一位的结果
//将长度较长的数字赋给num1,方便后面计算
if (num1.Length < num2.Length)
{
ChangeNum(ref num1, ref num2);
}
int flag;
for (int i = num2.Length-1; i >=0; i--)
{
//初始化上一位乘法中的数据
liCh.Clear();
flag = 0;
//计算第i位乘以第j位
for (int j = num1.Length - 1; j >= 0; j--)
{
liCh.Add((char)((num2[i] - '0') * (num1[j] - '0')+flag+'0'));
flag = (liCh[liCh.Count-1] -'0')/ 10;
liCh[liCh.Count - 1] = (char)((liCh[liCh.Count - 1] - '0') % 10+'0');
}
//若进位不为0,则在加进位
if (flag>0)
{
liCh.Add((char)(flag+'0'));
}
//添加结果集
liAllNum.Add(InvertOrder(new string(liCh.ToArray()))+new string('0',liAllNum.Count));
}
int count = 0;
string res="0";
//调用add方法,将每一位乘法所得的结果相加,即为结果
BigAdd addOper= new BigAdd();
while (count
{
res = addOper.Oper(res,liAllNum[count]);
count++;
}
return res;
}
}