#C7380. Number to English Words Converter

    ID: 51245 Type: Default 1000ms 256MiB

Number to English Words Converter

Number to English Words Converter

Given an integer between 0 and 999, convert the number into its English words representation. The conversion should follow the standard American English convention, for example, 123 should be converted to one hundred twenty three. The input begins with an integer T which denotes the number of test cases, followed by T lines each containing a single number. The program should output the word representation for each number on a new line.

The conversion should satisfy the following rules:

  1. For 0, the output must be: zero.
  2. For numbers in the range 1-19, use the corresponding word (e.g., one for 1, thirteen for 13, etc.).
  3. For tens from 20 to 90, use the tens words (e.g., twenty for 20, eighty for 80). If the number is not a multiple of 10, add the corresponding ones word (e.g., eighty five for 85).
  4. For numbers 100 and above, include the hundreds part followed by the tens and ones parts if applicable (e.g., one hundred fifteen for 115).

The problem requires you to read from standard input (stdin) and write to standard output (stdout). All answers in various programming languages must adhere to this format and pass all given test cases.

inputFormat

The first line of input contains an integer T (1 ≤ T ≤ 100), representing the number of test cases. Each of the next T lines contains a single integer n (0 ≤ n ≤ 999) as a string.

outputFormat

For each test case, output a single line containing the English words representation of the number.## sample

4
0
5
10
999
zero

five ten nine hundred ninety nine

</p>