Advertisement
Stan0033

Untitled

Jun 17th, 2021
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. namespace apps
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. //rounding numbebrs
  10.  
  11. string text = Console.ReadLine();
  12. int total = 0;
  13.  
  14. string[] Separated = text.Split(' ');
  15. double[] Nums = new double[Separated.Length];
  16. for (int i = 0; i < Separated.Length; i++)
  17. {
  18. Nums[i] = Convert.ToDouble(Separated[i]);
  19.  
  20.  
  21.  
  22.  
  23. double GetDecimal = ( Nums[i] - Math.Floor(Nums[i])) * 10;
  24.  
  25. if (GetDecimal == 5)
  26. {
  27. if (Nums[i] > 0)
  28. {
  29. Nums[i] = Math.Ceiling(Nums[i]);
  30. }
  31. else
  32. {
  33. Nums[i] = Math.Floor(Nums[i]);
  34. }
  35.  
  36. }
  37. else
  38. {
  39. Nums[i] = Math.Round(Nums[i]);
  40. }
  41.  
  42.  
  43. Console.WriteLine($"{Separated[i]} => {Nums[i]}");
  44.  
  45.  
  46. }
  47.  
  48.  
  49.  
  50.  
  51. }
  52.  
  53.  
  54. }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement