题解 | 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;
}
查看4道真题和解析