找字符串中不重复的字符的个数
#include<iostream>
#include<string>
using namespace std;
int main()
{
int count = 0;
int num[128] = { 0 };
string a;
getline(cin, a);
for (int i = 0; i < a.length(); i++)
{
if (a[i] >= 0 && a[i] <= 127)
{
num[a[i]]++;
}
}
for (int i = 0; i < 127; i++)
{
if (num[i] != 0)
count++;
}
cout << count;
}
版权声明:本文为qq_45848768原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。