Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace apps
- {
- class Program
- {
- static void Main(string[] args)
- {
- //rounding numbebrs
- string text = Console.ReadLine();
- int total = 0;
- string[] Separated = text.Split(' ');
- double[] Nums = new double[Separated.Length];
- for (int i = 0; i < Separated.Length; i++)
- {
- Nums[i] = Convert.ToDouble(Separated[i]);
- double GetDecimal = ( Nums[i] - Math.Floor(Nums[i])) * 10;
- if (GetDecimal == 5)
- {
- if (Nums[i] > 0)
- {
- Nums[i] = Math.Ceiling(Nums[i]);
- }
- else
- {
- Nums[i] = Math.Floor(Nums[i]);
- }
- }
- else
- {
- Nums[i] = Math.Round(Nums[i]);
- }
- Console.WriteLine($"{Separated[i]} => {Nums[i]}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement