hdu 1860 统计字符 (水)

点击打开链接

题目意思:输入两个字符串,输出第一个字符串中各个字符的个数!,注意空格也算,还有相同字符的情况下,要重复输出!
#include<stdio.h>
#include<string.h>
#define M 88
int main()
{
	char str[M],s[6];
	int cnt[6],i,j;
	while(gets(s),s[0]!='#')
	{
		gets(str);
		memset(cnt,0,sizeof(cnt));
		for(i=0;s[i];i++)
			for(j=0;str[j];j++)
				if(str[j]==s[i])
					cnt[i]++;
				for(i=0;s[i];i++)
					printf("%c %d\n",s[i],cnt[i]);
    }
	return 0;
}


原文地址:https://www.cnblogs.com/yyf573462811/p/6365234.html