Advertisement
IvanBorisovG

Cast

Jan 29th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Numerics;
  7.  
  8. namespace SomeNameSpace
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             var number = Console.ReadLine();
  15.  
  16.  
  17.             var split = number.Split('.');
  18.  
  19.  
  20.             var secondPart = "";
  21.  
  22.             if (split[1].Length<3)
  23.             {
  24.                 secondPart = split[1];
  25.  
  26.                 for (int i = split[1].Length; i < 3; i++)
  27.                 {
  28.                     secondPart += "0";
  29.                 }
  30.                
  31.             }
  32.             else
  33.             {
  34.                 secondPart = split[1].Substring(0,3);
  35.             }
  36.             Console.WriteLine($"{split[0]}.{secondPart}");
  37.            
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement