Advertisement
Fanta-MindTerror

maxNumbersInTwo

Dec 24th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1.  class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             while (true)
  6.             {
  7.                 Console.WriteLine("Введите первое число");
  8.                 int N = Convert.ToInt32(Console.ReadLine());
  9.                 Console.WriteLine("Введите второе число");
  10.                 int N2 = Convert.ToInt32(Console.ReadLine());
  11.  
  12.                 Console.WriteLine("Результат "+ maxNumbersInTwo(N,N2));
  13.             }
  14.         }
  15.  
  16.         static int maxNumbersInTwo(int a,int b)
  17.         {
  18.             int reservA = a;
  19.             int reservB = b;
  20.             int count = 0;
  21.             int count2 = 0;
  22.  
  23.             while(a > 0)
  24.             {
  25.                 count++;
  26.                 a /= 10;
  27.             }
  28.  
  29.             while (b > 0)
  30.             {
  31.                 count2++;
  32.                 b /= 10;
  33.             }
  34.  
  35.             if(count > count2)
  36.             {
  37.                 return reservA;
  38.             }
  39.             else
  40.             {
  41.                 return reservB;
  42.             }
  43.  
  44.  
  45.         }
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement