题解 | while

while

https://www.nowcoder.com/practice/173564fc07c146a88c408c92f4182c65

#include <bits/stdc++.h>
using namespace std;
int main(){
	int cnt = 0;
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i ++){
    	if(i == 0 and s[i] != 'w') cnt ++;
    	if(i == 1 and s[i] != 'h') cnt ++;
    	if(i == 2 and s[i] != 'i') cnt ++;
    	if(i == 3 and s[i] != 'l') cnt ++;
    	if(i == 4 and s[i] != 'e') cnt ++;
	}
	cout << cnt;
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务