Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.36 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 Ex._7
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string type = Console.ReadLine();
  14.             if (type == "char")
  15.             {
  16.                 char firstChar = Console.ReadLine()[0];
  17.                 char secondChar = Console.ReadLine()[0];
  18.                 char result = PrintMax(firstChar,secondChar);
  19.                 Console.WriteLine(result);
  20.             }
  21.  
  22.             else if (type == "int")
  23.             {
  24.                 int firstNum = int.Parse(Console.ReadLine());
  25.                 int secondNum = int.Parse(Console.ReadLine());
  26.                 int result = PrintMax(firstNum, secondNum);
  27.                 Console.WriteLine(result);
  28.  
  29.             }
  30.             else if (type == "string")
  31.             {
  32.                 string firstText = Console.ReadLine();
  33.                 string secondText = Console.ReadLine();
  34.                 string result = (PrintMax(firstText, secondText));
  35.                 Console.WriteLine(result);
  36.  
  37.             }
  38.         }
  39.  
  40.         private static char PrintMax(char firstChar, char secondChar)
  41.         {
  42.            
  43.             if (firstChar.CompareTo(secondChar) > 0) //ако е 1 - значи firstchar > secondchar
  44.             {
  45.               return (firstChar);
  46.             }
  47.  
  48.             else
  49.             {
  50.                return (secondChar); //ако е -1 - значи firstchar < secondchar
  51.  
  52.             }
  53.         }
  54.         private static int PrintMax(int firstNum, int secondNum)
  55.         {
  56.  
  57.             if (firstNum.CompareTo(secondNum) > 0) //ако е 1 - значи firstchar > secondchar
  58.             {
  59.                
  60.                 return (firstNum);
  61.                
  62.                
  63.             }
  64.  
  65.  
  66.          return (secondNum); //ако е -1 - значи firstchar < secondchar
  67.                
  68.            
  69.         }
  70.         private static string PrintMax(string firstText, string secondText)
  71.         {
  72.  
  73.             if (firstText.CompareTo(secondText) > 0) //ако е 1 - значи firstchar > secondchar
  74.             {
  75.                 return (firstText);
  76.             }
  77.  
  78.            
  79.                 return (secondText); //ако е -1 - значи firstchar < secondchar
  80.  
  81.            
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement