字符串问题归类--C和C++

1.去除重复字符串并排序

void DelRepeatedStrAndSort(char *str, int len)
{
    if (str == NULL || len < 1)
        return;
    int hash[256];
    memset(hash, 0, sizeof(hash));
    for (int i = 0; i < len; i++)
        ++hash[str[i]];
    for (int i = 0; i < 256; i++)
    {
        if (hash[i] != 0)
            putchar(i);
    }
}

你可能感兴趣的:(C和C++基础学习)