Chinese
In order to business needs boring extremely write a method of output Chinese digit, efficiency is passable, if you have any better method, the next.
1
2/**////<summary>
3///Chinese count
4///</summary>
5///<param name= "num" >[1-99999]</param>
6///<returns></returns>
7 public static string numtochinesenumstr (int num)
8 {
9 if (num <= 0 | | num > 99999)
throw new ArgumentException ("num");
One string[] Gradechar = new string[]{"", "ten", "Hundred", "thousand", "Million"};
string[] Digitchar = new string[]{"One", "two", "three", "four", "five", "six", "seven", "eight", "Nine"};
Char zero = ' 0 ';
14
int length = (int) math.log10 (num) + 1;
StringBuilder output = new StringBuilder (length);
int[] input = new Int[length];
int index =-1;
while (++index!= length)
20 {
INPUT[INDEX] = (num/(Length-index = 1 1: (int) math.pow))% 10;
22}
23
BOOL Needfix = false;
An if (input. Length = = 2 && input[0] = = 1)
num Needfix = true;
27
for (int pos = 0; pos < input. Length; POS + +)
29 {
if (input[pos] = = 0)
31 {
if (output[output. Length-1]!= Zero)
Output. Append (zero);
Continue;
35}
Or else if (! pos = = 0 && needfix))
37 {
Output. Append (Digitchar[input[pos]-1]);
39}
Output. Append (Gradechar[input. LENGTH-POS-1]);
41}
An if (output[output). Length-1] = = zero)
to output. Remove (output. Length-1, 1);
The return output. ToString ();
45}
46