文章

145

粉丝

143

获赞

21

访问

39.9k

头像
字母统计 题解:C
P1292 上海交通大学机试题
发布于2024年1月31日 22:52
阅读数 365

#include <stdio.h>

void Statics(char *s)
{
	int i,t[26] = {0};
	char *p = s;
	while(*p != '\0')
	{
		if(*p >= 'A' && *p <= 'Z')
		{
			t[*p - 65]++;
		}
		p++;
	}
	for(i = 0; i < 26; i++)
		printf("%c:%d\n",'A'+i,t[i]);
}

int main()
{
	char s[10000];
	while(scanf("%s",s) != EOF)
	{
		Statics(s);
	}
	
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发