58A题目网址
题目解析
1.输入字符串,问如果删去其中的一些自发,能否得到hello,如果能就输出YES,否则输出NO
举例:
输入:
ahhellllloou
输出:
YES
2.注意点:
因为C语言没有java中的匹配字符串,则新建立一个 word[6]=“hello”;
在循环中使用word去与s匹配,当匹配到了就
count++;
j++;
当count==5输出YES,否则输出NO
代码
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{char s[100]={'\0'};char word[6]="hello";int count=0,j=0;scanf("%s",s);for(int i=0;i<strlen(s);i++){if(word[j]==s[i]){count++;j++;}}if(count==5)printf("YES");else{printf("NO");}getchar();//接收回车符getchar();//这才是让控制台停住return 0;
}