给定一个字符串,找到最先出现的相同字符

来源:互联网 发布:数据来源有哪些 编辑:程序博客网 时间:2024/06/05 21:51
链接:https://www.nowcoder.com/questionTerminal/2a38887ce9ec4262856b40e5ae87e557
来源:牛客网

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;
}
阅读全文
0 0
原创粉丝点击