原帖上还是有错误,重新改下算了:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
char str[255];
char count[26];
main()
{
int j;
scanf ("请输入句子(255字节以内):\n%s",str);
for (j=0,str[j],j++)
{
if (str[j]==' ') ++j;
++count[tolower(str[j])-'a'];
};
for (j=0,j<26,j++) printf ("%c在句中出现%d次",'a'+j,count[j]);
getchar();
return 0;
}
这个是统计所有字母在句中出现的次数没错,
还有就是 tolower 函数可以实现 大写>>小写······
[ 本帖最后由 弈秋 于 2007-8-31 10:42 编辑 ]