Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _8.GreaterOfTwoValues
  8. {
  9.     class Program
  10.     {
  11.         static int GetMax(int a, int b)
  12.         {
  13.             if (a >= b)
  14.             {
  15.                 return a;
  16.             }
  17.  
  18.             else
  19.             {
  20.                 return b;
  21.             }
  22.         }
  23.  
  24.         static char GetMax(char a, char b)
  25.         {
  26.             if ((int)(a) >= (int)(b))
  27.             {
  28.                 return a;
  29.             }
  30.  
  31.             else
  32.             {
  33.                 return b;
  34.             }
  35.         }
  36.  
  37.         static string GetMax(string a, string b)
  38.         {
  39.             if (a.CompareTo(b) >= 0)
  40.             {
  41.                 return a;
  42.             }
  43.  
  44.             else
  45.             {
  46.                 return b;
  47.             }
  48.         }
  49.  
  50.         static void Main(string[] args)
  51.         {
  52.             string type = Console.ReadLine();
  53.  
  54.             if (type == "int")
  55.             {
  56.                 int a = int.Parse(Console.ReadLine());
  57.                 int b = int.Parse(Console.ReadLine());
  58.                 Console.WriteLine(GetMax(a, b));
  59.             }
  60.  
  61.             else if (type == "string")
  62.             {
  63.                 string a = Console.ReadLine();
  64.                 string b = Console.ReadLine();
  65.                 Console.WriteLine(GetMax(a, b));
  66.             }
  67.  
  68.  
  69.             else if (type == "char")
  70.             {
  71.                 char a = char.Parse(Console.ReadLine());
  72.                 char b = char.Parse(Console.ReadLine());
  73.                 Console.WriteLine(GetMax(a, b));
  74.             }
  75.  
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement