#include <stdio.h>
int main()
{
/* Write C code in this online editor and run it. */
char ch;
int i=0;
int k=0;
int num[26]={0};
printf("Input 字符串:");
ch=getchar();
while(ch!='\n')//判断是否输入回车
{
if(ch<='z'&&ch>='a')
{
k=ch-'a';
num[k]=num[k]+1;
}
ch=getchar();
}
for(i=0;i<=25;i++)
{
if(num[i]!=0)
{
printf("num of %c is %d\n",i+'a',num[i]);
}
}
}
标签:ch,小写字母,个数,C语言,int,num,printf,getchar From: https://www.cnblogs.com/riscv123/p/18332144