static void Money(int n)
{
string[] StrArry = new string[n.ToString().Length];
int[] arry=new int[n.ToString().Length];
for (int i = 0; i < n.ToString().Length; i++)
{
if (n > 9)
{
arry[i] = n % 10;
n = n / 10;
}
}
for (int j = 0; j < arry.Length; j++)
{
switch (arry[j])
{
case 1:
StrArry[j]="一";
break;
case 2:
StrArry[j] = "二";
break;
case 3:
StrArry[j] = "三";
break;
case 4:
StrArry[j] = "四";
break;
case 5:
StrArry[j] = "五";
break;
case 6:
StrArry[j] = "六";
break;
case 7:
StrArry[j] = "七";
break;
case 8:
StrArry[j] = "八";
break;
case 9:
StrArry[j] = "九";
break;
case 0:
StrArry[j] = "";
break;
}
switch (j)
{
case 0:
StrArry[j] += "元";
break;
case 1:
StrArry[j] += "十";
break;
case 2:
StrArry[j] += "百";
break;
case 3:
StrArry[j] += "千";
break;
case 4:
StrArry[j] += "万";
break;
case 5:
StrArry[j] += "十万";
break;
case 6:
StrArry[j] += "百万";
break;
}
}
for (int k = arry.Length-1; k >=0; k--)
{
Console.Write(StrArry[k]);
}
Console.WriteLine();
}
这是我的代码,想要得到输入一个整形数,返回一个中文人民币表达,
比如1234,一千二百三十四元
可是总是得不到想要的结果,不知道哪里错了,求指导 |