您的位置:首页 > 其它

杭电1219

2016-03-08 11:12 274 查看
题目描述:

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();
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: