Advertisement
YavorGrancharov

Float_or_Integer

Jun 9th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.31 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         string num = Console.ReadLine();
  8.         int value1;
  9.         double value2;
  10.         if (int.TryParse(num, out value1)) {
  11.             Console.Write(value1);
  12.         }
  13.         else if (double.TryParse(num, out value2)) {
  14.             Console.Write(Math.Round(value2, 0));
  15.         }
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement