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 _06.Catch_the_Thief
- {
- class Program
- {
- static void Main(string[] args)
- {
- string type = Console.ReadLine();
- int n = int.Parse(Console.ReadLine());
- long currNum = 0;
- long biggestValue = 0;
- long closestNum = 0;
- for (int i = 1; i <= n; i++)
- {
- if(type == "sbyte")
- {
- currNum = long.Parse(Console.ReadLine());
- if(currNum>=sbyte.MinValue && currNum <= sbyte.MaxValue)
- {
- if(currNum>closestNum && currNum<= sbyte.MaxValue)
- {
- closestNum = currNum;
- }
- }
- }
- else if(type == "int")
- {
- currNum = long.Parse(Console.ReadLine());
- if (currNum >= int.MinValue && currNum <= int.MaxValue)
- {
- if (currNum > closestNum && currNum <= int.MaxValue)
- {
- closestNum = currNum;
- }
- }
- }
- else if(type == "long")
- {
- currNum = long.Parse(Console.ReadLine());
- if (currNum >= long.MinValue && currNum <= long.MaxValue)
- {
- if (currNum > closestNum && currNum <= long.MaxValue)
- {
- closestNum = currNum;
- }
- }
- }
- }
- switch (type)
- {
- case "sbyte":
- sbyte output1 = (sbyte)closestNum;
- Console.WriteLine(output1);
- break;
- case "int":
- int output2 = (int)closestNum;
- Console.WriteLine(output2);
- break;
- case "long":
- long output3 = (long)closestNum;
- Console.WriteLine(output3);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement