#include "stdio.h"
#include "stdlib.h"
#include "string.h"
main()
{int i=0,t,dc=0,zm[26];
char a[100];
for(i=0;i<26;i++)
zm[i]=0;
gets(a);
i=0;
while(a[i]!='\0')
{ if(a[i]!=' ')
{while(a[i]>' ' )
{zm[a[i]-'a']++;i++;}
dc++;}
else
i++;
}
for(i=0;i<26;i++)
if(zm[i]>0)
printf("\n%c出现了%d次\t",i+'a',zm[i]);
printf("\n共有单词%d个\n",dc);
system("pause");
}
答案在北邮出版社郭浩志版C语言程序设计第131页的例7.23,程序太长了手机打不完啊!主要是根据str[i]-'A'和str[i]-'a'+26统记个数,将其按顺序存入数组c中计数。