using
System;
using
System.Collections.Generic;
using
System.Text;
using
Microsoft.VisualBasic;
namespace
TrancePY
{
class Program
{
static void Main(string[] args)
{
Console.Write("
请输入一连串汉字以回车键结束:"
);
string strHZ = Console.ReadLine();
string strPY="";
for (int i = 1; i < strHZ.Length+1; i++)
{
strPY += PYJM(Strings.Mid(strHZ, i, 1));
}
Console.Write("
该系列汉字的拼音简码分别为:"
+ strPY+"/n");
}
static string PYJM(string strWord)
{
if (MyAsc(strWord)<0)
{
if (MyAsc(MyLeft(strWord,1))<MyAsc("
啊"
))
{
return "0";
}
if (MyAsc(MyLeft(strWord,1))>=MyAsc("
啊"
) && MyAsc(MyLeft(strWord,1))<MyAsc("
芭"
))
{
return "A";
}
if (MyAsc(MyLeft(strWord,1))>=MyAsc("
芭"
) && MyAsc(MyLeft(strWord,1))<MyAsc("
擦"
))
{
return "B";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
擦"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
搭"
))
{
return "C";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
搭"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
蛾"
))
{
return "D";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
蛾"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
发"
))
{
return "E";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
发"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
噶"
))
{
return "F";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
噶"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
哈"
))
{
return "G";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
哈"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
击"
))
{
return "H";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
击"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
喀"
))
{
return "J";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
喀"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
垃"
))
{
return "K";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
垃"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
妈"
))
{
return "L";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
妈"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
拿"
))
{
return "M";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
拿"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
哦"
))
{
return "N";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
哦"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
啪"
))
{
return "O";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
啪"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
期"
))
{
return "P";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
期"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
然"
))
{
return "Q";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
然"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
撒"
))
{
return "R";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
撒"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
塌"
))
{
return "S";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
塌"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
挖"
))
{
return "T";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
挖"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
昔"
))
{
return "W";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
昔"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
压"
))
{
return "X";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
压"
) && MyAsc(MyLeft(strWord, 1)) < MyAsc("
匝"
))
{
return "Y";
}
if (MyAsc(MyLeft(strWord, 1)) >= MyAsc("
匝"
))
{
return "Z";
}
return "";
}
else
{
if (MyAsc(Strings.UCase(strWord))<= MyAsc("Z") && MyAsc(Strings.UCase(strWord)) >= MyAsc("A"))
return Strings.UCase(MyLeft(strWord, 1));
else
return strWord;
}
}
static int MyAsc(string strS)
{
return Strings.Asc(strS);
}
static string MyLeft(string strS,int intLength)
{
return Strings.Left(strS, intLength);
}
}
}