题意
判断字符串长度是奇数还是偶数。
思路
略
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include <cmath> #include <algorithm> #include <iostream> #include <cstring> #include <string> #include <stdio.h> #include <string.h> #include <ctype.h> #include <vector> #include <queue> using namespace std; int main(){ string name; cin >> name; bool vis[26]; memset(vis, 0, sizeof(vis)); for (int i = 0; i < name.size(); i++) { vis[name[i] - 'a'] = true; } int cnt = 0; for (int i = 0; i < 26; i++) { if (vis[i]) { cnt++; } } if (!(cnt % 2)) { cout << "CHAT WITH HER!" << endl; }else{ cout << "IGNORE HIM!" << endl; } return 0; } |