Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _07.GreaterOfTwoValues
- {
- class GreaterOfTwoValues
- {
- static void Main()
- {
- string type = Console.ReadLine();
- if (type == "int")
- {
- int firstInt = int.Parse(Console.ReadLine());
- int secondInt = int.Parse(Console.ReadLine());
- Console.WriteLine(PrintGreaterInteger(firstInt, secondInt));
- }
- else if (type == "char")
- {
- char firstChar = char.Parse(Console.ReadLine());
- char secondChar = char.Parse(Console.ReadLine());
- Console.WriteLine(PrintGreaterChar(firstChar, secondChar));
- }
- else
- {
- string firstString = Console.ReadLine();
- string secondString = Console.ReadLine();
- Console.WriteLine(PringGreaterString(firstString, secondString));
- }
- }
- static int PrintGreaterInteger(int firstInt, int secondInt)
- {
- if (firstInt >= secondInt)
- {
- return firstInt;
- }
- else
- {
- return secondInt;
- }
- }
- static char PrintGreaterChar(char firstChar, char secondChar)
- {
- if ((int)firstChar >= (int) secondChar)
- {
- return firstChar;
- }
- else
- {
- return secondChar;
- }
- }
- static string PringGreaterString(string firstString, string secondString)
- {
- if (firstString.Length >= secondString.Length)
- {
- return firstString;
- }
- else
- {
- return secondString;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement