B - Sleuth
Problem description
Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions whatsoever that can be answered with "Yes" or "No". All the rest agree beforehand to answer the questions like that: if the question’s last letter is a vowel, they answer "Yes" and if the last letter is a consonant, they answer "No". Of course, the sleuth knows nothing about it and his task is to understand that.
Unfortunately, Vasya is not very smart. After 5 hours of endless stupid questions everybody except Vasya got bored. That’s why Vasya’s friends ask you to write a program that would give answers instead of them.
The English alphabet vowels are: A, E, I, O, U, Y
The English alphabet consonants are: B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Z
Input
The single line contains a question represented by a non-empty line consisting of large and small Latin letters, spaces and a question mark. The line length does not exceed 100. It is guaranteed that the question mark occurs exactly once in the line — as the last symbol and that the line contains at least one letter.
Output
Print answer for the question in a single line: YES if the answer is "Yes", NO if the answer is "No".
Remember that in the reply to the question the last letter, not the last character counts. I. e. the spaces and the question mark do not count as letters.
Examples
Input
Is it a melon?
Output
NO
Input
Is it an apple?
Output
YES
Input
Is it a banana ?
Output
YES
Input
Is it an apple and a banana simultaneouSLY?
Output
YES
解题思路:简单判断一行中最后一个字母(非"?")是否为元音字母,如果是则输出"YES",否则输出"NO",水过!
AC代码:
#include<bits/stdc++.h>
using namespace std;
const char obj[]={'a','A','e','E','i','I','o','O','u','U','y','Y'};
bool fb(char ch){
for(int i=;i<;++i)
if(ch==obj[i])return true;
return false;
}
int main(){
char s[];gets(s);
int len=strlen(s);
for(int i=len-;i>=;--i){
if((s[i]>='A'&&s[i]<='Z')||(s[i]>='a'&&s[i]<='z')){
if(fb(s[i]))cout<<"YES"<<endl;
else cout<<"NO"<<endl;
break;
}
}
return ;
}
最新文章
- Java 组播
- XML与JSON的转换
- 实现listview的条目点击后改变背景颜色
- 系统上线后WCF服务最近经常死掉的原因分析总结
- upload.php --->;文件上传
- Codevs_1230_元素查找_(set/Hash)
- ubuntu设置WPA2-PSK的wifi热点(AP)——hostapd+dhcpd
- Oracle Enterprise linux 7 安装Oracle11gR2
- css3动画图片波纹效果
- Oracl Over函数
- 夏令营提高班上午上机测试 Day 1 解题报告
- 关于css兼容性问题及一些常见问题汇总
- gulp源码解析(一)—— Stream详解
- python之MySQL MySQLdb 推荐使用姿势,解决中文乱码
- [IOI2018]高速公路收费——二分查找+bfs
- python 正则表达式re模块
- Maven知识点积累二
- css盒子模型(box-sizing)
- 前端-javascript-正则表达式
- iOS开发总结--三方平台开发之分享
热门文章
- Windows如何正确的修改administrator用户名
- P1886 滑动窗口&;&;P1440 求m区间内的最小值
- Luogu P2068 统计和
- net core 配置Redis Cache
- Delphi 10.3.2最新消息
- MySQL之SQL优化详解(一)
- 【 Educational Codeforces Round 51 (Rated for Div. 2) F】The Shortest Statement
- 详解Cookie、LocalStorage、SessionStorage
- How do I drop a MongoDB database, from the command line?
- jenkins 构建被中断 脚本却还在执行