• B


    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代码:
     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 const char obj[12]={'a','A','e','E','i','I','o','O','u','U','y','Y'};
     4 bool fb(char ch){
     5     for(int i=0;i<12;++i)
     6         if(ch==obj[i])return true;
     7     return false;
     8 }
     9 int main(){
    10     char s[105];gets(s);
    11     int len=strlen(s);
    12     for(int i=len-1;i>=0;--i){
    13         if((s[i]>='A'&&s[i]<='Z')||(s[i]>='a'&&s[i]<='z')){
    14             if(fb(s[i]))cout<<"YES"<<endl;
    15             else cout<<"NO"<<endl;
    16             break;
    17         }
    18     }
    19     return 0;
    20 }
  • 相关阅读:
    LeetCode 79. 单词搜索
    LeetCode 1143. 最长公共子序列
    LeetCode 55. 跳跃游戏
    LeetCode 48. 旋转图像
    LeetCode 93. 复原 IP 地址
    LeetCode 456. 132模式
    LeetCode 341. 扁平化嵌套列表迭代器
    LeetCode 73. 矩阵置零
    LeetCode 47. 全排列 II
    LeetCode 46. 全排列
  • 原文地址:https://www.cnblogs.com/acgoto/p/9196736.html
Copyright © 2020-2023  润新知