set 应用
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>
using namespace std;
typedef long long ll;
const int maxn = 10000 + 7, INF = 0x3f3f3f3f, mod = 1e9 + 7;
char s[77777];
set<char> st;
int main() {
gets(s);
int len = strlen(s);
for(int i = 0; i < len; ++i)
if(s[i] >= 'a' && s[i] <= 'z') st.insert(s[i]);
cout << st.size() ;
return 0;
}
本文介绍了一个简单的C++程序,该程序使用STL中的set容器来统计输入字符串中出现的小写字母数量。通过逐个检查字符串中的字符并将其插入到set中(前提是该字符为小写字母),最终输出set中元素的数量。

被折叠的 条评论
为什么被折叠?



