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;
- class Pro_17_DiffIntegerSize
- {
- static void Main()
- {
- string input = Console.ReadLine();
- try
- {
- sbyte number = sbyte.Parse(input);
- Console.WriteLine("{0} can fit in:", number);
- Console.WriteLine("* sbyte");
- Console.WriteLine("* short");
- Console.WriteLine("* int");
- Console.WriteLine("* long");
- }
- catch (OverflowException)
- {
- try
- {
- byte number = byte.Parse(input);
- Console.WriteLine("{0} can fit in:", number);
- Console.WriteLine("* byte");
- Console.WriteLine("* short");
- Console.WriteLine("* ushort");
- Console.WriteLine("* int");
- Console.WriteLine("* uint");
- Console.WriteLine("* long");
- }
- catch (OverflowException)
- {
- try
- {
- short number = short.Parse(input);
- Console.WriteLine("{0} can fit in:", number);
- Console.WriteLine("* short");
- Console.WriteLine("* int");
- Console.WriteLine("* long");
- }
- catch (OverflowException)
- {
- try
- {
- ushort number = ushort.Parse(input);
- Console.WriteLine("{0} can fit in:", number);
- Console.WriteLine("* ushort");
- Console.WriteLine("* int");
- Console.WriteLine("* uint");
- Console.WriteLine("* long");
- }
- catch (OverflowException)
- {
- try
- {
- int number = int.Parse(input);
- Console.WriteLine("{0} can fit in:", number);
- Console.WriteLine("* int");
- Console.WriteLine("* uint");
- Console.WriteLine("* long");
- }
- catch (OverflowException)
- {
- try
- {
- uint number = uint.Parse(input);
- Console.WriteLine("{0} can fit in:", number);
- Console.WriteLine("* uint");
- Console.WriteLine("* long");
- }
- catch (OverflowException)
- {
- try
- {
- long number = long.Parse(input);
- Console.WriteLine("{0} can fit in:", number);
- Console.WriteLine("* long");
- }
- catch (OverflowException)
- {
- Console.WriteLine("{0} can't fit in any type", input);
- }
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement