Boy or Girl

举报
辰chen 发表于 2022/06/15 00:54:20 2022/06/15
【摘要】 文章目录 一、Boy or Girl总结 一、Boy or Girl 本题链接:Boy or Girl 题目: A. Boy or Girl time limit per test...

文章目录


一、Boy or Girl

本题链接Boy or Girl

题目

A. Boy or Girl
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Those days, many boys use beautiful girls’ photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he thought so). After that they talked very often and eventually they became a couple in the network.

But yesterday, he came to see “her” in the real world and found out “she” is actually a very strong man! Our hero is very sad and he is too tired to love again now. So he came up with a way to recognize users’ genders by their user names.

This is his method: if the number of distinct characters in one’s user name is odd, then he is a male, otherwise she is a female. You are given the string that denotes the user name, please help our hero to determine the gender of this user by his method.

Input
The first line contains a non-empty string, that contains only lowercase English letters — the user name. This string contains at most 100 letters.

Output
If it is a female by our hero’s method, print “CHAT WITH HER!” (without the quotes), otherwise, print “IGNORE HIM!” (without the quotes).

Examples

input
wjmzbmr

output
CHAT WITH HER!

input
xiaodao

output
IGNORE HIM!

input
sevenkplus

output
CHAT WITH HER!

Note
For the first example. There are 6 distinct characters in “wjmzbmr”. These characters are: “w”, “j”, “m”, “z”, “b”, “r”. So wjmzbmr is a female and you should print “CHAT WITH HER!”.

本博客给出本题截图

在这里插入图片描述
在这里插入图片描述

题意:如果输入的字符串中字符相同的个数是奇数的话就是男生,反之是女生

AC代码

#include <iostream>

using namespace std;

const int N = 110;

char s[N];
int res; 

int main()
{
	cin >> s;
	
	for (int i = 0; s[i]; i ++ )
	{
		bool flag = true;
		for (int j = 0; j < i; j ++ )
			if (s[i] == s[j])
				flag = false;
		
		if (flag) res ++;
	}
		
	if (res % 2) puts("IGNORE HIM!");
	else puts("CHAT WITH HER!");
	
	return 0;
}

  
 
  • 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

总结

quote 引号
forum 论坛
avatar 化身
determine 造成

水题,不解释

文章来源: chen-ac.blog.csdn.net,作者:辰chen,版权归原作者所有,如需转载,请联系作者。

原文链接:chen-ac.blog.csdn.net/article/details/117258656

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。