Georgi_Kirov

Untitled

Jan 22nd, 2020 (edited)
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.95 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp331
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             string input = Console.ReadLine();
  11.             if (input == "int")
  12.             {
  13.                 TestTheInputForInt(input);
  14.             }
  15.             else if (input == "char")
  16.             {
  17.                 TestTheInputForChar(input);
  18.             }
  19.             else if (input == "string")
  20.             {
  21.                 TestTheInputForString(input);
  22.             }
  23.            
  24.         }
  25.         private static void TestTheInputForInt(string input)
  26.         {
  27.            
  28.                 int nomer1 = int.Parse(Console.ReadLine());
  29.                 int nomer2 = int.Parse(Console.ReadLine());
  30.  
  31.                 int min = Math.Min(nomer1, nomer2);
  32.                 int max = Math.Max(nomer1, nomer2);
  33.  
  34.                 Console.WriteLine(max);
  35.         }
  36.         private static void TestTheInputForChar(string input)
  37.         {        
  38.                 char char1 = char.Parse(Console.ReadLine());
  39.                 char char2 = char.Parse(Console.ReadLine());
  40.  
  41.                 if (char1 > char2)
  42.                 {
  43.                     Console.WriteLine(char1);
  44.                 }
  45.                 else
  46.                 {
  47.                     Console.WriteLine(char2);
  48.                 }
  49.         }
  50.         private static void TestTheInputForString(string input)
  51.             {
  52.                     string purvoIme = Console.ReadLine();
  53.                     string vtoroIme = Console.ReadLine();
  54.  
  55.                     int duljinaNaString = purvoIme.Length;
  56.                     int duljinaNa2String = vtoroIme.Length;    
  57.  
  58.                     if (duljinaNaString > duljinaNa2String)
  59.                     {
  60.                         Console.WriteLine(purvoIme);
  61.                     }
  62.                     else
  63.                     {
  64.                         Console.WriteLine(vtoroIme);
  65.                     }  
  66.             }
  67.     }
  68. }
Add Comment
Please, Sign In to add comment