Witam. Poniżej przedstawiam program, który przekazuje wartości do tabeli, wyświetla je w postaci 10-cio cyfrowych liczb i dodaje. Próbuję przerobić ten program tak by wykonywał mnożenie. Czy ktoś mnie naprowadzi na rozwiązanie? Z góry dzięki
int n = 10;
int i, A, B, C;
int[] a = new int[n];
int[] b = new int[n];
int[] c = new int[n];
Console.Write("Enter A: ");
A = int.Parse(Console.ReadLine());
Console.Write("Enter B: ");
B = int.Parse(Console.ReadLine());
for (i = 0; i < n; ++i)
{
a[i] = A / (int)Math.Pow(10, i) % 10;
b[i] = B / (int)Math.Pow(10, i) % 10;
}
Console.Write("a = |");
for (i = n - 1; i >= 0; --i)
Console.Write(a[i] + "|");
Console.WriteLine();
Console.Write("b = |");
for (i = n - 1; i >= 0; --i)
Console.Write(b[i] + "|");
Console.WriteLine();
int carry = 0;
for (i = 0; i < n; ++i)
{
c[i] = (carry + a[i] + b[i]) % 10;
carry = (carry + a[i] + b[i]) / 10;
}
Console.Write("c = |");
for (i = n - 1; i >= 0; --i)
Console.Write(c[i] + "|");
Console.WriteLine();
C = 0;
for (i = 0; i < n; ++i)
C = C + (int)Math.Pow(10, i) * c[i];
Console.WriteLine("C = " + C);
Console.ReadKey();
}
}