Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Program
- {
- public static void Main()
- {
- var type = Console.ReadLine().ToLower();
- if (type == "int") {
- int first = int.Parse(Console.ReadLine());
- int second = int.Parse(Console.ReadLine());
- int max = GetMax(first, second);
- Console.WriteLine(max);
- }
- if (type == "char") {
- char first = char.Parse(Console.ReadLine());
- char second = char.Parse(Console.ReadLine());
- char max = GetMax((char)first, (char)second);
- Console.WriteLine(max);
- }
- if (type == "string") {
- string first = Console.ReadLine();
- string second = Console.ReadLine();
- string max = GetMax(first, second);
- Console.WriteLine(max);
- }
- }
- static int GetMax(int first, int second) {
- if (first > second) {
- return first;
- }
- else {
- return second;
- }
- }
- static char GetMax(char first, char second) {
- if (first > second) {
- return first;
- }
- else {
- return second;
- }
- }
- static string GetMax(string first, string second) {
- if (first.CompareTo(second) > 0) {
- return first;
- }
- else {
- return second;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement