#include <iostream>
using namespace std;
char getFirstSingleChar(char* s)
{
if(s==NULL || *s==0)
return 0;
int len = strlen(s);
unsigned int h_table[256] = {0};
int i;
for(i=0; i<len; i++)
h_table[s[i]]++;
for(i=0; i<256; i++)
if(h_table[i]==1)
return i;
}
int main()
{
cout<<getFirstSingleChar("abcac")<<endl;
return 0;
}
第一个只出现一次的字符
最新推荐文章于 2021-01-14 11:18:00 发布