原题链接:
思维点:
- 创建比较字符串,逐个比较
ac代码:
#include<iostream>
#include<string>
using namespace std;
int main() {
string s;
cin >> s;
string t = "hello";//创建比较字符串
int count = 0, len = s.length();
for(int i = 0, j = 0; i < len && j < 5; i++) {
if(t[j] == s[i]) {
count++;
j++;
}
}
if(count == 5) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}