1. 程式人生 > >HDoj-AC Me

HDoj-AC Me

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxn 100005
int main()
{
	char s[maxn];
	char c;
	int a[26] = { 0 };
	int first = 1;
	while (gets_s(s))
	{
		first = 0;
		if(first)
		c = getchar();
		memset(a, 0, sizeof(a));
		for (int i = 0; i < strlen(s); i++)
		{
			for (int j = 0; j < 26; j++)
				if (s[i] == (j + 'a'))
					a[j]++;
		}
		for (int i = 0; i < 26; i++)
			printf("%c:%d\n",i+'a', a[i]);
		printf("\n");
	}
	system("pause");
	return 0;
}