Advertisement
Guest User

Untitled

a guest
Oct 27th, 2023
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. namespace _03.RoundingNumbers
  2. {
  3.     internal class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.  
  8.             double[] input = Console.ReadLine()
  9.                 .Split(" ")
  10.                 .Select(double.Parse)
  11.                 .ToArray();
  12.  
  13.  
  14.             for (int i = 0; i < input.Length; i++)
  15.             {
  16.                 var roundedVal = Math.Round(input[i], 0, MidpointRounding.AwayFromZero).ToString();
  17.                 if (roundedVal == "-0")
  18.                 {
  19.                     roundedVal = "0";
  20.                 }
  21.  
  22.                 Console.WriteLine($"{input[i]} => {roundedVal}");
  23.             }
  24.  
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement