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;
    }
     
  • 相关阅读:
    清理计算机硬盘
    DIY-组装
    go函数类型的使用
    go同步互斥锁
    Go读写文件
    go mod
    go html
    channel
    arp和rarp协议
    自己实现的反射
  • 原文地址:https://www.cnblogs.com/jxust-jiege666/p/6433094.html
Copyright © 2011-2022 走看看