Advertisement
Dimitar46

Multiply Big Number

May 19th, 2022
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. namespace StringProcessingExercise5MultiplyBigNumber
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             //int n = 1234;
  11.             //int firstD = n / 1000;
  12.             //int secondD = n / 100 % 10;
  13.             //int thirdD = n / 10 %10;
  14.             //int fourthD = n % 10;
  15.  
  16.             //Console.WriteLine(firstD);
  17.             //Console.WriteLine(secondD);
  18.             //Console.WriteLine(thirdD);
  19.             //Console.WriteLine(fourthD);
  20.             string textN1 = Console.ReadLine();
  21.             string result = string.Empty;
  22.             byte number2 = byte.Parse(Console.ReadLine());
  23.             int ostatak = 0;
  24.             for (int i = textN1.Length-1; i >= 0; i--)
  25.             {
  26.                 int currentNumber = int.Parse(textN1[i].ToString());
  27.                 int multi = (number2 * currentNumber) + ostatak;              
  28.                 result += multi%10;
  29.                 ostatak = multi / 10;
  30.             }
  31.             if (ostatak != 0)
  32.             {
  33.                 result += ostatak;
  34.             }
  35.  
  36.             for(int i = result.Length - 1; i >= 0; i--)
  37.             {
  38.                 Console.Write(result[i]);
  39.             }
  40.          
  41.             Console.WriteLine();
  42.         }
  43.     }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement