codeforces 58A-C语言解题报告
生活随笔
收集整理的這篇文章主要介紹了
codeforces 58A-C语言解题报告
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
58A題目網(wǎng)址
題目解析
1.輸入字符串,問如果刪去其中的一些自發(fā),能否得到hello,如果能就輸出YES,否則輸出NO
舉例:
輸入:
ahhellllloou
輸出:
YES
2.注意點(diǎn):
因?yàn)镃語言沒有java中的匹配字符串,則新建立一個(gè) word[6]=“hello”;
在循環(huán)中使用word去與s匹配,當(dāng)匹配到了就
count++;
j++;
當(dāng)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();//這才是讓控制臺(tái)停住return 0; }總結(jié)
以上是生活随笔為你收集整理的codeforces 58A-C语言解题报告的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 招行普卡和金卡的区别:四个方面来分析
- 下一篇: Android Gradle 多渠道打包