zoukankan      html  css  js  c++  java
  • A

    Problem description

    HQ9+ is a joke programming language which has only four one-character instructions:

    • "H" prints "Hello, World!",
    • "Q" prints the source code of the program itself,
    • "9" prints the lyrics of "99 Bottles of Beer" song,
    • "+" increments the value stored in the internal accumulator.

    Instructions "H" and "Q" are case-sensitive and must be uppercase. The characters of the program which are not instructions are ignored.

    You are given a program written in HQ9+. You have to figure out whether executing this program will produce any output.

    Input

    The input will consist of a single line p which will give a program in HQ9+. String p will contain between 1 and 100 characters, inclusive. ASCII-code of each character of p will be between 33 (exclamation mark) and 126 (tilde), inclusive.

    Output

    Output "YES", if executing the program will produce any output, and "NO" otherwise.

    Examples

    Input

    Hi!

    Output

    YES

    Input

    Codeforces

    Output

    NO

    Note

    In the first case the program contains only one instruction — "H", which prints "Hello, World!".

    In the second case none of the program characters are language instructions.

    解题思路:题目的意思就是如果输入字符串中有'H','Q','9'这三个字符中的任意一个,程序都会有输出即为"YES",否则为没有输出即为"NO",注意字符'+'只是内部累加值并不会使程序有输出,所以这种情况不算,简单水过。

    AC代码:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 int main(){
     4     char str[105];bool flag=false;
     5     cin>>str;
     6     for(int i=0;str[i]!='';++i){
     7         if(str[i]=='H'||str[i]=='Q'||str[i]=='9'){flag=true;break;}
     8     }
     9     if(flag)cout<<"YES"<<endl;
    10     else cout<<"NO"<<endl;
    11     return 0;
    12 }
  • 相关阅读:
    Hibernate第二天:Hibernate的一级缓存、其他的API
    Hibernate第一天(Hibernate的环境搭建、Hibernate的API、Hibernate的CRUD)
    数据结构基础(一)数组,矩阵
    MyEclipseSVN插件百度云下载
    修改CentOS主机名
    Word中增加仿宋GB-2312字体
    Linux系统常用基本命令总结
    SpringBoot视频教程 百度云
    VM虚拟机中linux centOS 联网单网卡配置教程
    Java正则表达式匹配日期及基本使用
  • 原文地址:https://www.cnblogs.com/acgoto/p/9125121.html
Copyright © 2011-2022 走看看