### 找出字符串中出现频率最少的字符，并将其去除

`/*程序功能描述：找出字符串中出现频率最小的字母，并将其去除;Author:NerohHwang;Date:10/9/2013 Wednesday;*/#include<iostream>#include<string.h>using namespace std;int main(){    char * Str = "dhajkhfkablcjnakjyhrweuipqhydhjasbvfjhlksdabklfjhslkMm";    //下面两个数组对照小写和大写，最后统一到一个数组中    int iArrSmall[26];    int iArrBig[26];    int iSum[26];                                //统计    for (int i = 0; i < 26; i ++)    {        iArrSmall[i] = iArrBig[i] =  0;           //全部初始化为0            }    for(int i = 0;  i < strlen(Str); i++)    {        if (Str[i] > 96 && Str[i] < 123)          //如果是比96大，即是属于小写字母范围;当然，不能超过小写z的范围        {            iArrSmall[Str[i]-97]++;        }        else if (Str[i] <= 90 && Str[i] > 64)    //大写字母范围        {            iArrBig[Str[i]-65]++;        }        else        {            cout<<"Invalid letter!"<<endl;            system("pause");            exit(1);        }    }    for (int i = 0; i < 26 ; ++i)    {        iSum[i] = iArrBig[i] + iArrSmall[i];    }    //下面对统计结果进行选择，直接挑出最小的那一项即可,统计数需大于零,即该字母必须出现过    int iSmallestIndex = iSum[0];    for (int i = 1; i < 26; ++i)    {        if (iSmallestIndex > iSum[i] && iSum[i] > 0)        {            iSmallestIndex = i;        }    }    cout<<"The smallest letter is "<<char(iSmallestIndex+97)<<" or "<<char(iSmallestIndex+65)<<endl;    cout<<"There are "<<iSum[iSmallestIndex]<<" of them"<<endl;    //更新数据    char strNew[256];    int  index = 0;    for (int i = 0; i < strlen(Str) ; i++)    {      if (int(Str[i]) != (iSmallestIndex+97) && int(Str[i]) != (iSmallestIndex+65))        {             strNew[index] = Str[i];             index++;        }    }    strNew[index+1] = '\0';    cout<<strlen(strNew)<<endl;    cout<<strNew<<endl;    //地址重新赋值，覆盖原数据    Str = strNew;    cout<<Str<<endl;    return 0;}`