zoukankan      html  css  js  c++  java
  • Chat room

    /*

    Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word "hello". For example, if Vasya types the word "ahhellllloou", it will be considered that he said hello, and if he types "hlelo", it will be considered that Vasya got misunderstood and he didn't manage to say hello. Determine whether Vasya managed to say hello by the given word s.

    Input

    The first and only line contains the word s, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters.

    Output

    If Vasya managed to say hello, print "YES", otherwise print "NO".

    Example

    Input
    ahhellllloou
    Output
    YES
    Input
    hlelo
    Output
    NO

    */
    #include <iostream>
    #include <string.h>
    #include <stdio.h>
    using namespace std;
    
    char a[110];
    
    int main()
    {
        cin >> a;
        getchar();
        int k = 0;
        int i,j,n,m,v;
        for(i = 0; i <= strlen(a); i ++)
        {
            if(a[i] == 'h')
            {
                k ++;
                int I=i;
                i=strlen(a);
                //cout  << k << endl;
                for(int j = (I+1); j <= strlen(a); j++)
                {
                    if(a[j] == 'e')
                    {
                        k++;
                        int J=j;
                        j=strlen(a);
                        for(int n = J+1; n <= strlen(a); n++)
                        {
                            if(a[n] == 'l')
                            {
                                k++;
                                int N=n;
                                n=strlen(a);
                                //cout  << k << endl;
                                for(int m = N+1; m <= strlen(a); m++)
                                {
                                    if(a[m] == 'l')
                                    {
                                        k++;
                                        int M=m;
                                        m=strlen(a);
                                        //cout  << k << endl;
                                        for(int v = M+1; v <= strlen(a); v++)
                                        {
                                            if(a[v] == 'o')
                                                {
                                                    k++;
                                                    v=strlen(a);
                                                }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if(k >= 5)
            cout << "YES" <<endl;
        else cout << "NO" <<endl;
        //cout  << k << endl;
        return 0;
    }
     
  • 相关阅读:
    文本框设置只读,后台可获取
    div 在同一行的 CSS处理
    在标签中添加属性
    (转)如何使用SignalTap II觀察reg與wire值? (SOC) (Verilog) (Quartus II) (SignalTap II)
    (转)如何使用ModelSim對Megafunction或LPM作仿真? (SOC) (MegaCore) (ModelSim)
    (笔记)TSL235新型光感器件强烈推荐使用
    (转)如何增加SignalTap II能觀察的reg與wire數量? (SOC) (Quartus II) (SignalTap II)
    (转) 如何將10進位轉2進位? (C/C++) (C)
    (转)如何使用ModelSim作前仿真與後仿真? (SOC) (Quartus II) (ModelSim)
    (笔记)关于LM3S片内FLASH编程的一点建议
  • 原文地址:https://www.cnblogs.com/jxust-jiege666/p/6433094.html
Copyright © 2011-2022 走看看