Advertisement
Guest User

Untitled

a guest
Jun 17th, 2018
1,276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Test
  5. {
  6.     class Test
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string num1 = Console.ReadLine().TrimStart(new char[] { '0' });
  11.             int num2 = int.Parse(Console.ReadLine());
  12.             if (num2 == 0)
  13.             {
  14.                 Console.WriteLine(0);
  15.                 return;
  16.             }
  17.             int decimalReminder = 0;
  18.             int currentMultiplication = 0;
  19.             List<int> result = new List<int>();
  20.             for (int i = num1.Length - 1; i >= 0; i--)
  21.             {
  22.                 int currentDigit = num1[i] - '0';
  23.                 currentMultiplication = currentDigit * num2;
  24.                 currentMultiplication += decimalReminder;
  25.                 result.Add(currentMultiplication % 10);
  26.                 decimalReminder = currentMultiplication / 10;
  27.             }
  28.             if (decimalReminder > 0)
  29.             {
  30.                 result.Add(decimalReminder);
  31.             }
  32.             result.Reverse();
  33.             Console.WriteLine(string.Join("", result));
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement