Guest User

Untitled

a guest
May 27th, 2017
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.82 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Globalization;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Practice
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             var num1 = decimal.Parse(Console.ReadLine());
  15.             var num2 = decimal.Parse(Console.ReadLine());
  16.  
  17.             var bigger = Math.Max(num1, num2); string small = "";
  18.             var smaller = Math.Min(num1, num2);string big = "";
  19.             ulong minvalue=0;
  20.             if (bigger <= byte.MaxValue && bigger >= byte.MinValue)
  21.                 big = "byte";
  22.             else if (bigger <= ushort.MaxValue && bigger >= ushort.MinValue)
  23.                 big = "ushort";
  24.             else if (bigger <= uint.MaxValue && bigger >= uint.MinValue)
  25.                 big = "uint";
  26.             else if (bigger <= ulong.MaxValue && bigger >= ulong.MinValue)
  27.                 big = "ulong";
  28.             if (smaller <= byte.MaxValue && smaller >= byte.MinValue)
  29.             {
  30.                 small = "byte"; minvalue = byte.MaxValue;
  31.             }
  32.             else if (smaller <= ushort.MaxValue && smaller >= ushort.MinValue)
  33.             {
  34.                 small = "ushort"; minvalue = ushort.MaxValue;
  35.             }
  36.             else if (smaller <= uint.MaxValue && smaller >= uint.MinValue)
  37.             {
  38.                 small = "uint"; minvalue = uint.MaxValue;
  39.             }
  40.             else if (smaller <= ulong.MaxValue && smaller >= ulong.MinValue)
  41.             {
  42.                 small = "ulong"; minvalue = ulong.MaxValue;
  43.             }
  44.  
  45.             Console.WriteLine($"bigger type: {big}");
  46.             Console.WriteLine($"smaller type: {small}");
  47.             Console.WriteLine($"{bigger} can overflow {small} {Math.Round(bigger/minvalue)} times ");
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment