zoukankan      html  css  js  c++  java
  • Codeforces Beta Round #96 (Div. 2) 133A. HQ9+

    A. HQ9+

    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.

    Sample test(s)

    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.

    解题报告:就是判断一个字符串中是否含有Q、H、9.如果含有则输出YES!,唉!英语太差!第一次理解错了!

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    using namespace std;
    const int N =110;
    char str[N];
    int main()
    {
    int len,i,flag;
    scanf("%s",str);
    len=strlen(str);
    flag=0;
    for(i=0;i<len;i++)
    {
    if(str[i]=='Q'||str[i]=='H'||str[i]=='9')
    {
    flag=1;
    break;
    }
    }
    if(flag)
    {
    printf("YES\n");
    }
    else
    {
    printf("NO\n");
    }
    return 0;
    }
  • 相关阅读:
    202012-2 期末预测之最佳阈值
    [蓝桥杯][2017年第八届真题]k倍区间
    116. 飞行员兄弟
    P1985 [USACO07OPEN]翻转棋 Fliptile S
    P2882 [USACO07MAR]Face The Right Way G
    730. 机器人跳跃问题
    202012-1 期末预测之安全指数
    SpringMVC 的 JDBC 做 增删改查后 一些总结
    22. VUE 的 V-model 修饰符
    21. VUE 的 V-model 指令(双向绑定input)【主要绑定表单】
  • 原文地址:https://www.cnblogs.com/lidaojian/p/2277371.html
Copyright © 2011-2022 走看看