veno0

Untitled

Feb 6th, 2020
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace ConsoleApp5
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string input = Console.ReadLine();
  11.             if(input == "string")
  12.             {
  13.                 string firstString = Console.ReadLine();
  14.                 string secondString = Console.ReadLine();
  15.                 string outputString = GetMax(firstString, secondString);
  16.                 Console.WriteLine(outputString);
  17.             }
  18.             else if (input == "int")
  19.             {
  20.                 int firstNumber = int.Parse(Console.ReadLine());
  21.                 int secondNumber = int.Parse(Console.ReadLine());
  22.                 int outputInt = GetMax(firstNumber, secondNumber);
  23.                 Console.WriteLine(outputInt);
  24.             }
  25.             else
  26.             {
  27.                 char firstChar = char.Parse(Console.ReadLine());
  28.                 char secondChar = char.Parse(Console.ReadLine());
  29.                 char outputChar = GetMax(firstChar, secondChar);
  30.                 Console.WriteLine(outputChar);
  31.             }
  32.  
  33.         }
  34.          public static string GetMax(string a,string b)
  35.         {
  36.            if(a.CompareTo(b) < 0)
  37.             {
  38.                 return b;
  39.             }
  40.             else
  41.             {
  42.                 return a;
  43.             }
  44.            
  45.         }
  46.         public static int GetMax(int a,int b)
  47.         {
  48.             int output = Math.Max(a, b);
  49.             return output;
  50.         }
  51.         public static char GetMax(char a,char b)
  52.         {
  53.             int output = Math.Max((int)a, b);
  54.             return (char)output;
  55.  
  56.  
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment