说“hello”-字符串

题号: 10073
时限:1000ms
限制内存:32768KB
题目:
说“hello”


描述

小明想要用键盘打出“hello”, 但是打错了, 现在已知小明打出的字符串, 请问小明是否可以仅通过删除其中的一些字符, 使这个字符串变成“hello”.

输入格式

一个字符串, 长度范围为[1, 1000], 表示打出的字符串, 仅含小写字母.
输出格式

如果可以变成“hello”, 输出“YES”, 否则输出“NO”.
输入样例

ahheelloo
输出样例

YES
#include<iostream>
using namespace std;
int main()
{
    char a[1111];
    int count=0;
    char b[5]={'h','e','l','l','o'};
    cin>>a;
    for(int i=0;a[i]!='\0';++i)
    if(a[i]==b[count])
    count++;
    if(count==5)
    cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
} 

猜你喜欢

转载自blog.csdn.net/gz153016/article/details/80437430