Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Problem08._Greater_of_Two_Values
- {
- internal class Program
- {
- public static void Main(string[] args)
- {
- string type = Console.ReadLine();
- if (type.Equals("int"))
- {
- int a = int.Parse(Console.ReadLine());
- int b = int.Parse(Console.ReadLine());
- Console.WriteLine( GetMaxInt(a, b));
- }
- if (type.Equals("string"))
- {
- string a = Console.ReadLine();
- string b = Console.ReadLine();
- Console.WriteLine(GetMaxString(a, b));
- }
- if (type.Equals("char"))
- {
- char a =char.Parse( Console.ReadLine());
- char b =char.Parse( Console.ReadLine());
- Console.WriteLine(GetMaxChar(a, b));
- }
- }
- static int GetMaxInt(int a, int b)
- {
- if (a > b) {return a;}
- else {return b;}
- }
- static string GetMaxString(string a, string b)
- {
- if (a.Length > b.Length) {return a;}
- else {return b;}
- }
- static char GetMaxChar(char a, char b)
- {
- if ((int) a > (int) b) {return a;}
- else{ return b;}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement