Advertisement
MT_Linkin

03. Rounding Numbers

Jan 26th, 2022
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 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.  
  7. namespace _3.Rounding_Numbers_2
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. double[] nums = Console.ReadLine().Split().Select(double.Parse).ToArray();
  15.  
  16. for (int i = 0; i < nums.Length; i++)
  17. {
  18. if (nums[i] == 0)
  19. {
  20. nums[i] = 0;
  21. }
  22. Console.WriteLine($"{nums[i]} => {(int)Math.Round(nums[i], MidpointRounding.AwayFromZero)}");
  23. }
  24. }
  25. }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement