Advertisement
Prohause

Untitled

Jun 12th, 2016
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4.  
  5. class MultiplyBigNumber
  6. {
  7. static void Main()
  8. {
  9. char[] firstNumber = Console.ReadLine().TrimStart(new char[] { '0' }).ToArray();
  10. int second = int.Parse(Console.ReadLine());
  11.  
  12. StringBuilder output = new StringBuilder();
  13.  
  14. int first = 0;
  15. int toadd = 0;
  16. int result = 0;
  17. for (int i = 0; i < firstNumber.Length; i++)
  18. {
  19. first = int.Parse(Convert.ToString(firstNumber[firstNumber.Length - (i + 1)]));
  20. result = ((first*second) + toadd) % 10;
  21. if ((first*second + toadd) >= 10)
  22. {
  23. toadd = (first*second+toadd)/10;
  24. }
  25. else
  26. {
  27. toadd = 0;
  28. }
  29. output.Append(Convert.ToString(result));
  30. }
  31.  
  32. if (toadd > 0)
  33. {
  34. output.Append(Convert.ToString(toadd));
  35. }
  36. char[] newOutput = output.ToString().ToCharArray();
  37. Array.Reverse(newOutput);
  38. Console.WriteLine(string.Concat(newOutput));
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement