#include <stdio.h>
#include <stdlib.h>
typedef int bool;
typedef int Status;
int main()
{
int a[256]={0}; /*这是因为C语言的ascll码(常见ascll码+扩展ascll码)共有256个,就创建
长度为256的数组用于统计各个字符出现的次数,以便于根据下标还原ascll码,
通过下标还原也能减小时间复杂度,而不是一一遍历数组是否已记录某个字符*/
char c[100];
scanf("%s",c);
char find_str[256]={'0'};
for(int i=0;i<strlen(c);i++)
{
a[(int)c[i]]+=1;
}
int count=0;
for (int i=0;i<256;i++)
{
if(a[i]!=0)
{
find_str[count++]=(char)i;
}
}
printf("只出现过一次的字符为:");
for(int i=0;i<strlen(find_str);i++)
{
printf("%c",find_str[i]);
}
if(strlen(find_str)==0)
{
printf("Not Find!");
}
//按照asckll码大小由小到大输出,这在上面的遍历就可以看出。
}
运行效果: