@CycleWeeb/

check writing tool

C#

No description

fork
loading
Files
  • main.cs
  • main.exe
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;

class MainClass {
  static string[] digits = new string[] {
    "Zero", 
    "One",
    "Two",
    "Three",
    "Four",
    "Five",
    "Six",
    "Seven",
    "Eight",
    "Nine",
  };

  static string[] teens = new string[] {
    "Ten",
    "Eleven",
    "Twelve",
    "Thirteen",
    "Fourteen",
    "Fifteen",
    "Sixteen",
    "Seventeen",
    "Eighteen",
    "Nineteen"
  };

  static string[] tens = new string[] {
    "Twenty",
    "Thirty",
    "Forty",
    "Fifty",
    "Sixty",
    "Seventy",
    "Eighty",
    "Ninety"
  };

    static string NumberToWords(int number) {
      if(number < 10){
        return digits[number];
      }
      if(number < 20){
        return teens[number - 10];
      }
      if(number < 100){
        int high = number / 10;
        int low = number % 10;
        string s = tens[high-2];
        if (low > 0){
          s += "-" + digits[low];
        }
        return s;
      }
      if(number < 1000){
        int h = number / 100;
        int r = number % 100;
        string hundreds = NumberToWords(h) + " hundred";
        if (r > 0){
          hundreds += " " + NumberToWords(r);
        }
        return hundreds;
      }
      if(number < 1000000){
        int th = number / 1000;
        int oth = number % 1000;
        string thousands = NumberToWords(th) + " thousand";
        if (oth > 0){
          thousands += " " + NumberToWords(oth);
        }
        return thousands;
      }
      if(number < 1000000000){
        int b = number / 1000000;
        int q = number % 1000000;
        string millions = NumberToWords(b) + " million";
        if (q > 0){
          millions += " " + NumberToWords(q);
        }
        return millions;
      }
      return number.ToString();
    }

  public static void Main (string[] args) {
    Console.WriteLine("༼•̃͡ ɷ•̃͡༽");
    while(true){
      int number = int.Parse(Console.ReadLine());
      Console.WriteLine(NumberToWords(number));
    }
  }
}