TheBulgarianWolf

Float rounder

Oct 11th, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Numerics;
  4.  
  5. namespace SoftuniExercisesWithVariables
  6. {
  7.     class Program
  8.     {
  9.        
  10.  
  11.         static void Main(string[] args)
  12.         {
  13.             string numbers = Console.ReadLine();
  14.             string[] nums = numbers.Split(" ");
  15.             float[] floatNums = new float[nums.Length];
  16.             float[] rounded = new float[nums.Length];
  17.             for (int i = 0; i < nums.Length; i++)
  18.             {
  19.                 floatNums[i] = float.Parse(nums[i]);
  20.             }
  21.             for(int k = 0;k< nums.Length; k++)
  22.             {
  23.                 rounded[k] = (float)Math.Ceiling(floatNums[k]);
  24.             }
  25.  
  26.             for(int line = 0; line < nums.Length; line++)
  27.             {
  28.                 Console.WriteLine($"{floatNums[line]} => {rounded[line]:f0}");
  29.             }
  30.            
  31.         }
  32.     }
  33. }
  34.  
Add Comment
Please, Sign In to add comment