Advertisement
Pietras286

Reprezentacja liczb typu float

Dec 13th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. public class Test
  2. {
  3. static void Main(string[] args)
  4.         {
  5.             int t = int.Parse(Console.ReadLine());
  6.             for (int i = 0; i < t; i++)
  7.             {
  8.                 string wynik = Konwertuj(float.Parse(Console.ReadLine()));
  9.                 string[] tab = wynik.Split('-');
  10.                 wynik = "";
  11.                 for (int j = tab.Length - 1; j >= 0; j--)
  12.                 {
  13.                     if (tab[j][0] == '0')
  14.                     {
  15.                         wynik += tab[j][1];
  16.                     }
  17.                     else
  18.                     {
  19.                         wynik += tab[j];
  20.                     }
  21.                     if (j>0)
  22.                     {
  23.                         wynik += " ";
  24.                     }
  25.                 }
  26.  
  27.                 Console.WriteLine(wynik.ToLower());
  28.             }
  29.         }
  30.  
  31.         private static string Konwertuj(float v)
  32.         {
  33.             return BitConverter.ToString(BitConverter.GetBytes(v));
  34.         }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement