You're interested in figuring out the number of case-insensitive unique characters in some string. This sounds simple and easily-automated, so you just decide to just go for it.
Input
Your input will consist of an integer N followed by a newline. N test cases will follow, all separated by newlines. Each test case is a string of letters containing some combination of letters (upper- and lower-case are allowed), the space character, and the characters contained in the string ?!.'$%&*:;,.
Output
Your output should consist of one integer per case, separated by whitespace, indicating the number of case-insensitive unique characters contained in the input string.
Constraints
5 ≤ N ≤ 25
Input strings will not exceed 100 characters in length.
#include <iostream>
#include <cctype>
#include <map>
#include <cstdio>
#include <string>
using namespace std;
main(){
map<char, int> chr;
int n;char y;string t;
cin>>n;
while(n--){
getline(cin,t);
while((y=getchar())!='\n'&&!iscntrl(y)){
if(isupper(y))y=tolower(y);
chr[y]=1;
}
cout<<chr.size()<<endl,chr.clear();
}
}
No comments:
Post a Comment