給定一個字串,找到最先出現的相同字元
來源:牛客網
char first_double_char(const char *str)
{
int len=strlen(str);
char first_double;
bool isfound=false;
for(int i=1;i!=len-1;i++)
{
char temp=str[i];
for(int j=0;j!=i;j++)
{
if(str[j]==temp)
{
first_double=temp;
isfound=true;
}
if(isfound)
break;
}
if(isfound)
break;
}
return first_double;
}