标签:char oid array 第一个 statistic 字符串 ons ati generate
static void Main(string[] args)
{
string mystring = "abcdefghijklmnopqrstuvwxyz";
GenerateStatistics(mystring);
Console.ReadLine();
}
static int[] GenerateStatistics(string str)
{
char[] mychar = str.ToCharArray();
int[] myarr = new int[26];
for (int i = 0; i < mychar.Length; i++)
{
for (int j = 0; j < myarr.Length; j++)
{
if (j == (int)mychar[i] - 97)
{
myarr[j] += 1;
}
}
}
foreach (int k in myarr)
{
Console.Write(k+" ");
}
return myarr;
}
标签:char oid array 第一个 statistic 字符串 ons ati generate
原文地址:http://www.cnblogs.com/lhhqq-114/p/6607542.html