数字换成大写
?úÂëÈçÏÂ?º
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace ConvertNumber
{
class Program
{
static void Main(string[] args)
{
GetZWNum(Console.ReadLine());
Console.ReadLine();
}
public static string GetZWNum(string strN)
{
string[] strNum = { "Ò?", "??", "Èþ", "ËÁ", "Îé", "Â?", "Æâ",
"?Æ", "?Á" };
int bl = -1;
bool ch = true;
int len = strN.Length;
if (len > 24)
{
Console.WriteLine("ÄúÊäÈëµÄÊý×Ö?ý?ó??ÎÞ??ת????");
return "";
}
string strResult = "";
string[] strSZ = new string[len];
for (int i = 0; i < len; i++)
{
strSZ[i] = strN.Substring(i, 1);
if (!Regex.IsMatch(strSZ[i], "^[0-9]$"))
{
Console.WriteLine("ÄúÊäÈëµÄÊý×Öº?ÓÐ?ÇÊý×Ö?ûºÅ??");
return "";
}
if (strSZ[0] == "0" && ch)//?ìÑéÊ×Î??öÏÖÁãµÄÇé?ö
{
if (i != len - 1 && strSZ[i] == "0" && strSZ[i + 1] !=
"0")
bl = i;
else
ch = false;
}
}
for (int i = 0; i < len; i++)
{
int num = len - i;
if (strSZ[i] != "0")
{
strResult += strNum[Convert.ToInt32(strSZ[i]) -
1];//????À,??Êý×Öת???ÉÖÐÎÄ?óÐ?Êý×Ö
//?ÓÉϵ?Î?
if (num % 4 == 2)
strResult += "Ê?";
if (num % 4 == 3)
strResult += "?Û";
if (num % 4 == 0)
strResult += "Ǫ";
if (num % 4 == 1)
{
if (num / 4 == 1)
strResult += "Èf";
if (num / 4 == 2)
strResult += "ÒÚ";
if (num / 4 == 3)
strResult += "Èf";
if (num / 4 == 4)
strResult += "ÒÚ";
if (num / 4 == 5)
strResult += "Èf";
}
}
else
{
if (i > bl)
{
if ((i != len - 1 && strSZ[i + 1] != "0" && (num
- 1) % 4 != 0))
{
//?Ë??ÅÐ?Ï??0????ÊÇ?öÏÖÔÚÄ?Î???ÇÒÏÂÒ?Î?Ò???ÊÇ??0????
//Èç 10012332 ÔÚ?Ë???Á??Ó??ÃΪÒ?ǪÁãÒ?Èf??
strResult += "Áã";
}
if (i != len - 1 && strSZ[i + 1] != "0")
{
switch (num)
{
//?Ë???öÏÖµÄÇé?öÊÇÈç 10002332????0???öÏÖÔÚÍòÎ?ÉÏ?ÍÓ??Ã?ÓÉÏÒ??ö??Èf???Á?ÉÒ?ǪÈfÁã??ǪÈþ?ÛÈþÊ???
case 5: strResult += "Èf";
break;
case 9: strResult += "ÒÚ";
break;
case 13: strResult += "Èf";
break;
}
}
if (i != len - 1 && strSZ[i + 1] != "0" && (num - 1) % 4 == 0)
{
//?Ë???öÏÖµÄÇé?öÊÇÈç 10002332????0???öÏÖÔÚÍòÎ?ÉÏ?ÍÓ??Ã?ÓÉÏÒ??ö??Áã???Á?ÉÒ?ǪÈfÁã??ǪÈþ?ÛÈþÊ???
strResult += "Áã";
}
}
}
}
return strResult;
}
}
}