Run ID:115781
提交时间:2025-04-04 16:53:50
#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; // 读取输入字符串 string target = "hello"; int targetIndex = 0; // 目标字符串的指针 for (char c : s) { // 遍历输入字符串 if (c == target[targetIndex]) { // 如果当前字符匹配 targetIndex++; // 移动目标字符串的指针 if (targetIndex == target.size()) { // 如果目标字符串匹配完成 cout << "YES" << endl; return 0; // 提前结束程序 } } } cout << "NO" << endl; // 如果遍历完输入字符串仍未匹配完成 return 0; }