c语言统计输入字符串有多少不同的字母

版权声明:成都软件测试交流群,339614248,欢迎你的加入 https://blog.csdn.net/louishu_hu/article/details/79581775
int main()
{
char cString[100];
int i,j,count;
gets(cString);
count=0;
if(cString[0]=='\0'){
printf("请输入字符");
printf("朋友,机会只有一次,拜拜!");
}
else if(cString[0]==' '){
printf("不要输入空格");
printf("朋友,机会只有一次,拜拜!");
}
else{
for(i=0;i<strlen(cString);i++){
for(j=0;j<i;j++){
if(cString[j]==cString[i]){
count-=1;
break;}
}
count+=1;
}
}
printf("该字符串含有%d个字母!\n",count);
return 0;
}

猜你喜欢

转载自blog.csdn.net/louishu_hu/article/details/79581775