C#控制台程序 输入一个万以内的数字,将它转换成中文大写的人民币数。

 我来答
百度网友b357d1f
2010-03-23 · TA获得超过1642个赞
知道小有建树答主
回答量:1022
采纳率:0%
帮助的人:791万
展开全部
static void Main(string[] args)
{
string c="NULL";
Console .WriteLine("请输入 10000以内的数字!");
string a = Console.ReadLine();
string[] dw = "仟,佰,拾,圆".Split(',');
for (int i = 0; i < a.Length; i++)
{
if (a.Length == 4) c = dw[i];
if (a.Length == 3) c = dw[i+1];
if (a.Length == 2) c = dw[i+2];
if (a.Length == 1) c = dw[i+3];
switch (a[i])
{
case '0':if (a[1] == '0' || a[2] == '0') Console.Write("零") ; break;
case '1': Console.Write("壹" + c); break;
case '2': Console.Write("贰" + c); break;
case '3': Console.Write("叁" + c); break;
case '4': Console.Write("肆" + c); break;
case '5': Console.Write("伍" + c); break;
case '6': Console.Write("陆" + c); break;
case '7': Console.Write("柒" + c); break;
case '8': Console.Write("捌" + c); break;
case '9': Console.Write("玖" + c); break;
}
}
Console.ReadLine();
}
真不好意思 !!现在修改过来 了!修改后,尾数如果为0也可以读出来的!像“yaobing0687”朋友写的那个在确很好!但尾数为0就超出数组了!嘿嘿,分可能还是我拿哦!~
yaobing0687
2010-03-23 · TA获得超过988个赞
知道小有建树答主
回答量:1309
采纳率:0%
帮助的人:926万
展开全部
//楼上的少了啊~~不对.
static void Main(string[] args)
{
Console .WriteLine("请输入 10000以内的数字!");
string a = Console.ReadLine();
int l = a.Length;
if(l<5){
char[] money = a.ToCharArray();
string[] number = "壹,贰,叁,肆,伍,陆,柒,捌,玖".Split(',');
string[] danwei = "千,百,拾,元".Split(',');
string new_a = "";
for (int i = 0; i < l; i++)
{
new_a += number[int.Parse(money[i].ToString())- 1];
new_a+=danwei[4-(l-i)];
}
Console.Write(new_a); break;

}
Console.ReadLine();
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式