using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication3 ... { class Program ...{ static void Main(string[] args) ...{ string DataSouces = ""; while ((DataSouces = Console.ReadLine()) != "exit") ...{ //异常处理 try ...{ Console.WriteLine(ChangDataForChinese(DataSouces)); } catch ...{ } } } private static string ChangDataForChinese(string _StrSouces) ...{ string RetuStr = ""; string[] ss = ...{ "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖", " 拾" }; string[] t = ...{ "", "", "拾", "佰", "仟", "萬", "拾萬", "佰萬", "仟萬", "亿", "拾亿" }; for (int i = 0; i < _StrSouces.Length; i++) ...{ int k = Convert.ToInt16(_StrSouces[i]) - 48; if (k == 0) ...{ if (RetuStr != "" && RetuStr[RetuStr.Length - 1] != '零') RetuStr += ss[0]; continue; } RetuStr += ss[k] + t[_StrSouces.Length - i]; } return (RetuStr) + "圆整"; } private static string SpiteStr(string RetuStr) ...{ if (RetuStr.IndexOf("仟萬") > 0 && RetuStr.IndexOf("佰萬") > 0) RetuStr = RetuStr.Replace("仟萬", "仟"); if (RetuStr.IndexOf("仟萬") > 0 && RetuStr.IndexOf("拾萬") > 0) RetuStr = RetuStr.Replace("仟萬", "仟"); if (RetuStr.IndexOf("仟萬") > 0 && RetuStr.IndexOf("萬",RetuStr.IndexOf("仟萬") + 2) > 0) RetuStr = RetuStr.Replace("仟萬", "仟"); if (RetuStr.IndexOf("佰萬") > 0 && RetuStr.IndexOf("拾萬") > 0) RetuStr = RetuStr.Replace("佰萬", "佰"); if (RetuStr.IndexOf("佰萬") > 0 && RetuStr.IndexOf("萬", RetuStr.IndexOf("佰萬") + 2) > 0) RetuStr = RetuStr.Replace("佰萬", "佰"); if (RetuStr.IndexOf("拾萬") > 0 && RetuStr.LastIndexOf("萬", RetuStr.IndexOf("拾萬") + 2) > 0) RetuStr = RetuStr.Replace("拾萬", "拾"); RetuStr = RetuStr.TrimEnd(new Char[]...{'零'}); return RetuStr; } }}