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 _10.DataOverflow
- {
- class DataOverflow
- {
- static void Main(string[] args)
- {
- ulong firstNum = ulong.Parse(Console.ReadLine());
- ulong secondNum = ulong.Parse(Console.ReadLine());
- ulong biggerNum = Math.Max(firstNum, secondNum);
- ulong smallerNum = Math.Min(firstNum, secondNum);
- string bigType = "";
- string smallType = "";
- ulong smallNumType = 0;
- if (biggerNum >= smallerNum)
- {
- if (biggerNum > byte.MinValue && biggerNum <= byte.MaxValue)
- {
- bigType = "byte";
- }
- else if (biggerNum > ushort.MinValue && biggerNum <= ushort.MaxValue)
- {
- bigType = "ushort";
- }
- else if (biggerNum > uint.MinValue && biggerNum <= uint.MaxValue)
- {
- bigType = "uint";
- }
- else if (biggerNum > ulong.MinValue && biggerNum <= ulong.MaxValue)
- {
- bigType = "ulong";
- }
- if (smallerNum > byte.MinValue && smallerNum <= byte.MaxValue)
- {
- smallType = "byte";
- smallNumType = byte.MaxValue;
- }
- else if (smallerNum > ushort.MinValue && smallerNum <= ushort.MaxValue)
- {
- smallType = "ushort";
- smallNumType = ushort.MaxValue;
- }
- else if (smallerNum > uint.MinValue && smallerNum <= uint.MaxValue)
- {
- smallType = "uint";
- smallNumType = uint.MaxValue;
- }
- else if (smallerNum > ulong.MinValue && smallerNum <= ulong.MaxValue)
- {
- smallType = "ulong";
- smallNumType = ulong.MaxValue;
- }
- Console.WriteLine($"bigger type: {bigType}");
- Console.WriteLine($"smaller type: {smallType}");
- Console.WriteLine($"{biggerNum} can overflow {smallType} {Math.Round((double)biggerNum / smallNumType)} times");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment