tranerius

DigitToText

Mar 13th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. class DigitToText
  2. {
  3.     static void Main()
  4.     {
  5.         System.Console.WriteLine(DigitToString(123456789));
  6.     }
  7.  
  8.     static string DigitToString(long value_to_convert)
  9.     {
  10.         long order_of_number = 10;
  11.         string to_text = "";
  12.         string[] text_nums = { "нуль", "один", "два", "три", "четыре", "пять", "шесть", "семь", "восемь", "девять" };
  13.         while ((value_to_convert / (order_of_number / 10)) > 0)
  14.         {
  15.             to_text = to_text.Insert(0, text_nums[(value_to_convert % order_of_number) / (order_of_number / 10)] + " ");
  16.             order_of_number *= 10;
  17.         }
  18.         return to_text;
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment