题目描述:
Ignatius is doing his homework now. The teacher gives him some articles and asks him to tell how many times each letter appears.
It's really easy, isn't it? So come on and AC ME.
水题,注意格式,直接AC:
using System;
namespace a1
{
class Program
{
public static void Main(string[] args)
{
string str = string.Empty;
while((str = Console.ReadLine())!=null){
int[] a=new int[26];
for(int i=0;i<26;i++)
a[i]=0;
char[] ch=str.ToCharArray();
for(int i=0;i<str.Length;i++)
if(ch[i]>='a' && ch[i]<='z') a[ch[i]-'a']++;
for(int i=0;i<26;i++)
Console.WriteLine((char)('a'+i)+":"+a[i]);
Console.WriteLine();
}
}
}
}