题解 | 字符个数统计
字符个数统计
https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
#include <iostream> #include <string> #include <cstring> #include <cstdio> #include <cmath> #include <map> #include <algorithm> #include <vector> #include <set> #include <queue>//队列 #include <stack> //栈 //#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' #define pii pair<int, int> //queue<int> que; //set<int> s; //stack<int> st; void solve() { //scanf("%d", &); //printf("\n", ); /* cout << "手慢无" << endl; cout << "骗你的,手快也无" << endl; cout << "haha ^_^" << endl; */ //vector<int>a(n); //sort(a.begin(), a.end()); //map<int, int>mp; string s; cin>>s; map<char,int>mp; int ans=0; for(int i=0;i<s.size();i++) { if(mp[s[i]]==0) { mp[s[i]]++; ans++; } } cout<<ans; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while (t--) { solve(); cout << endl; } return 0; }#牛客春招刷题训练营#