Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _09._Greater_of_Two_Values
- {
- class Program
- {
- static void Main(string[] args)
- {
- string type = Console.ReadLine();
- if (type == "int")
- {
- int firstElement = int.Parse(Console.ReadLine());
- int secondElement = int.Parse(Console.ReadLine());
- Console.WriteLine(FineMaxElement(firstElement, secondElement));
- }
- else if (type == "char")
- {
- char firstElement = char.Parse(Console.ReadLine());
- char secondElement = char.Parse(Console.ReadLine());
- Console.WriteLine(FineMaxElement(firstElement, secondElement));
- }
- else if (type == "string")
- {
- string firstElement = Console.ReadLine();
- string secondElement = Console.ReadLine();
- Console.WriteLine(FineMaxElement(firstElement, secondElement));
- }
- }
- static string FineMaxElement(string firstElement, string secondElement)
- {
- if (firstElement.CompareTo(secondElement) >= 0)
- {
- return firstElement;
- }
- else
- {
- return secondElement;
- }
- }
- static char FineMaxElement(char firstElement, char secondElement)
- {
- if (firstElement > secondElement)
- {
- return firstElement;
- }
- else
- {
- return secondElement;
- }
- }
- static int FineMaxElement(int firstElement, int secondElement)
- {
- return Math.Max(firstElement, secondElement);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment