Codeforces Round #253 (Div. 2) A. Anton and Letters

http://codeforces.com/problemset/problem/443/A

题意:输入一段字符串,输出其中不同的字母个数。

PS:
输入的是一个字符串,它只是长的像个数组。例如{b, a, b, a}。每个字母之间有个,和空格。

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <bits/stdc++.h>
using namespace std;

set<char> st;
// 用set只保存不重复的字母

int main() {
string s;
getline(cin, s);
for (int i = 1; i < (int)s.size(); i += 3) {
if (s[i] >= 'a' && s[i] <= 'z') st.insert(s[i]);
}
cout << st.size() << endl;
return 0;
}