Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- class MultiplyBigNumber
- {
- static void Main()
- {
- char[] firstNumber = Console.ReadLine().TrimStart(new char[] { '0' }).ToArray();
- int second = int.Parse(Console.ReadLine());
- StringBuilder output = new StringBuilder();
- int first = 0;
- int toadd = 0;
- int result = 0;
- for (int i = 0; i < firstNumber.Length; i++)
- {
- first = int.Parse(Convert.ToString(firstNumber[firstNumber.Length - (i + 1)]));
- result = ((first*second) + toadd) % 10;
- if ((first*second + toadd) >= 10)
- {
- toadd = (first*second+toadd)/10;
- }
- else
- {
- toadd = 0;
- }
- output.Append(Convert.ToString(result));
- }
- if (toadd > 0)
- {
- output.Append(Convert.ToString(toadd));
- }
- char[] newOutput = output.ToString().ToCharArray();
- Array.Reverse(newOutput);
- Console.WriteLine(string.Concat(newOutput));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement