请问如何将数字转换为大写汉字C?

2026-04-24 14:552阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计360个文字,预计阅读时间需要2分钟。

请问如何将数字转换为大写汉字C?

csharpusing System;using System.Collections.Generic;using System.Text;

namespace Bignum{ class Program { static string[] bigNum={ 零, 壹, 贰, 叁, 肆, 伍, 陆, 柒, 捌, 玖 }; static string[] wei={ 元, 拾, 佰, 仟, 万, 拾, 佰, 仟, 亿, 拾, 佰, 仟 };

static void Main() { Console.WriteLine(请输入一个整数:); string input=Console.ReadLine(); string result=ConvertToChinese(input); Console.WriteLine(转换结果: + result); }

static string ConvertToChinese(string num) { if (string.IsNullOrEmpty(num) || !int.TryParse(num, out int number)) return 输入错误;

if (number <0) return 负数不支持;

if (number==0) return bigNum[0];

string result=; int length=num.Length; for (int i=0; i

请问如何将数字转换为大写汉字C?

using System;
using System.Collections.Generic;
using System.Text;
namespace bignum
{
class Program
{
static string[] bigNum ={ "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
static String[] wei ={ "元", "拾", "佰", "仟", "万" };
static String[] swei ={ "角", "分" };
static string getnum(string i)
{
int tt=Convert.ToInt32(i);
return bigNum[tt];

}
static void Main(string[] args)
{
float num = 0.3f;
string temp = num.ToString();
string strbig = "";
int bi = temp.IndexOf(".");
int si = 0;
if (bi == -1)
{
bi = temp.Length;
temp += ".00";
si = 0;
}
else
{
si = temp.Length - (bi + 1);
}
int j=bi;
Console.Write("{0} {1} {2}",temp.Length, bi, si);
for (int i = 0; i < bi; i++)
{
strbig += getnum(temp.Substring(i,1));
strbig +=wei[j-1];
j--;
}
temp = temp.Substring(bi+1, si);
for (int i = 0; i < si; i++)
{
strbig += getnum(temp.Substring(i, 1));
strbig += swei[i];
}
Console.WriteLine(strbig);
}
}
}

本文共计360个文字,预计阅读时间需要2分钟。

请问如何将数字转换为大写汉字C?

csharpusing System;using System.Collections.Generic;using System.Text;

namespace Bignum{ class Program { static string[] bigNum={ 零, 壹, 贰, 叁, 肆, 伍, 陆, 柒, 捌, 玖 }; static string[] wei={ 元, 拾, 佰, 仟, 万, 拾, 佰, 仟, 亿, 拾, 佰, 仟 };

static void Main() { Console.WriteLine(请输入一个整数:); string input=Console.ReadLine(); string result=ConvertToChinese(input); Console.WriteLine(转换结果: + result); }

static string ConvertToChinese(string num) { if (string.IsNullOrEmpty(num) || !int.TryParse(num, out int number)) return 输入错误;

if (number <0) return 负数不支持;

if (number==0) return bigNum[0];

string result=; int length=num.Length; for (int i=0; i

请问如何将数字转换为大写汉字C?

using System;
using System.Collections.Generic;
using System.Text;
namespace bignum
{
class Program
{
static string[] bigNum ={ "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
static String[] wei ={ "元", "拾", "佰", "仟", "万" };
static String[] swei ={ "角", "分" };
static string getnum(string i)
{
int tt=Convert.ToInt32(i);
return bigNum[tt];

}
static void Main(string[] args)
{
float num = 0.3f;
string temp = num.ToString();
string strbig = "";
int bi = temp.IndexOf(".");
int si = 0;
if (bi == -1)
{
bi = temp.Length;
temp += ".00";
si = 0;
}
else
{
si = temp.Length - (bi + 1);
}
int j=bi;
Console.Write("{0} {1} {2}",temp.Length, bi, si);
for (int i = 0; i < bi; i++)
{
strbig += getnum(temp.Substring(i,1));
strbig +=wei[j-1];
j--;
}
temp = temp.Substring(bi+1, si);
for (int i = 0; i < si; i++)
{
strbig += getnum(temp.Substring(i, 1));
strbig += swei[i];
}
Console.WriteLine(strbig);
}
}
}