两位数

两位数

问题描述:

我需要一个程序,它接受一个两位数(例如22")并返回22".我为主要方法启动了以下内容,但对于字符串方法没有任何内容

I need a program that takes a two digit number such as "22" and returns "Twenty Two". I have the following started for the main method but have nothing for the string method

        static string TwoDigit(int n)
    {

    }
    static void Main(string[] args)
    {
        for (int i = 0; i <= 19; i++)
            Console.WriteLine("{0}: {1}", i, TwoDigit(i));
        for (int i = 20; i <= 110; i += 7)
            Console.WriteLine("{0}: {1}", i, TwoDigit(i));
    }

我不知道现有的程序,但编写函数会很容易.
我会将 int 转换为字符串,然后对每个字符执行 switch 语句.
第一个开关将处理二十"、三十"等.
第二个开关将处理一、二、三等.
您将需要为青少年提供一个特殊情况,他们只会为每个人吐出单词.

I don't know of an existing program but it would be easy to write the function.
I would convert the int to a string then do a switch statement on each character.
The first switch would handle the "Twenty", "Thirty", etc.
The second switch would handle one, two, three, etc.
You will need to have a special case for the teens that just spits out the word for each.