Advertisement
ivan_gy6ev

Multiply big number

Jul 3rd, 2017
242
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _07.Multiply_Big_Number
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var firstStr = Console.ReadLine();
  14. var secondStr = Console.ReadLine();
  15.  
  16. var multiplyResult = 0;
  17. var reminder =0;
  18. string newNumber = string.Empty;
  19. for (int i = firstStr.Length-1; i>=0; i--)
  20. {
  21.  
  22. int value = (firstStr[i] - 48) * (secondStr[0]-48) + reminder;
  23. //Console.WriteLine(value);
  24. if (value>9)
  25. {
  26. reminder = value / 10; //Console.WriteLine(reminder);
  27. value = value % 10; //Console.WriteLine(value);
  28. }
  29. newNumber += value;
  30.  
  31. }
  32. if (reminder != 0) newNumber += reminder;
  33. newNumber = new string(newNumber.Reverse().ToArray());
  34. Console.WriteLine(newNumber);
  35. }
  36. }
  37. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement