题解 CF236A 【Boy or Girl】

· · 题解

这道题实在是太水了!!!

思路:定义一个bool变量,来记录字母是不是被判过。直接上代码。

#include<bits/stdc++.h>
using namespace std;
string s;
int tot=0;   //tot记录不同字符的个数。
bool t[255];   //t记录字符是不是被记录过。
int main()
{
    memset(t,0,sizeof(t));   //先将t全部初始化为false。
    getline(cin,s);
    for(int i=0;i<s.size();i++)
    {
        if(!t[(int)s[i]])
        {
            tot++;
            t[(int)s[i]]=1;
        }   //如果这个字符以前没有出现过,tot自增,
                           //并把这个字符的相应位置改为true。
    }
    if(tot%2)cout<<"IGNORE HIM!"<<endl;
    else cout<<"CHAT WITH HER!"<<endl;
            //输出tot相对应的答案(注意:全部都是大写)。
    return 0;
}

珍爱生命,远离抄袭,蟹蟹