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;
    }
     
  • 相关阅读:
    Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
    react 报错:'React' must be in scope when using JSX react/react-in-jsx-scope
    锋超R2200服务器U盘自检
    EF MySql 连接错误
    sqlalchemy插入数据遇到的一个BUG
    风哥Linux系统运维工程师培训实战教程(入门篇.共20套)
    Django
    Django
    Django 配置 sitemap 接口
    MySQL中 replace与replace into的区别与使用方法(干货分享)
  • 原文地址:https://www.cnblogs.com/jxust-jiege666/p/6433094.html
Copyright © 2011-2022 走看看