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.Numerics;
- using System.Text;
- using System.Threading.Tasks;
- namespace _17.DifferentIntegersSize
- {
- class Program
- {
- static void Main(string[] args)
- {
- string a = Console.ReadLine();
- try
- {
- long n = long.Parse(a);
- //BigInteger n = BigInteger.Parse(Console.ReadLine());
- //string n = Console.ReadLine();
- // long n = long.Parse(Console.ReadLine());
- List<string> storeNumber = new List<string>();
- string sbytes = "sbyte";
- string bytes = "byte";
- string shorts = "short";
- string ushorts = "ushort";
- string ints = "int";
- string uints = "uint";
- string longs = "long";
- if (n >= sbyte.MinValue && n <= sbyte.MaxValue)
- {
- storeNumber.Add(sbytes);
- }
- if (n >= byte.MinValue && n <= byte.MaxValue)
- {
- storeNumber.Add(bytes);
- }
- if (n >= short.MinValue && n <= short.MaxValue)
- {
- storeNumber.Add(shorts);
- }
- if (n >= ushort.MinValue && n <= ushort.MaxValue)
- {
- storeNumber.Add(ushorts);
- }
- if (n >= int.MinValue && n <= int.MaxValue)
- {
- storeNumber.Add(ints);
- }
- if (n >= uint.MinValue && n <= uint.MaxValue)
- {
- storeNumber.Add(uints);
- }
- if (n >= long.MinValue && n <= long.MaxValue)
- {
- storeNumber.Add(longs);
- }
- Console.WriteLine("{0} can fit in:", n);
- for (int i = 0; i < storeNumber.Count; i++)
- {
- Console.WriteLine("* {0}", storeNumber[i]);
- }
- }
- catch (OverflowException)
- {
- //BigInteger n = BigInteger.Parse(Console.ReadLine());
- //string n = Console.ReadLine();
- Console.WriteLine("{0} can't fit in any type",a);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement