华为OJ基础篇-找出字符串中第一个只出现一次的字符

来源:互联网 发布:jsp与php的区别 编辑:程序博客网 时间:2024/04/30 10:56

找出字符串中第一个只出现一次的字符

void HWoj(){    int book[130] = { 0 };    char* ptr = "asdfasdfo";    int len = strlen(ptr);    for (int i = 0; i < len; ++i)    {        ++book[ptr[i]];    }    for (int i = 0; i < 130; ++i){        if (book[i] == 1)            cout << (char)i << " ";    }    cout << endl;}
0 0