题目描述
对于给定的一个字符串,统计其中一共出现了多少种不同的字符。
输入
输入的第一行是一个整数n,表示测试实例的个数,每一组测试实例为一行字符串
输出
对于每一组测试实例,输出一个整数,代表这一行一共出现了多少种不同的字符
样例输入
2
0123abc
qqqqwwwwee
样例输出
7
3
代码内容
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
bool cmp(char a,char b)
{
return a<b;
}
int main()
{
int m,j,i,a[1000],n;
char b[100];
cin>>j;
while(j--)
{
getchar();
gets(b);
n=strlen(b);
sort(b,b+n,cmp);
m=unique(b,b+n)-b;
cout<<m<<endl;
}
return 0;
}