题解 | while

while

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

#include <iostream>
using namespace std;

int main() {
    string str;
    cin>>str;
    string s="while";
    int cnt=0;
    for(int i=0;i<5;i++)
    {
        if(s[i]!=str[i])
            cnt++;
    }
    cout<<cnt;
}

笑死硪了。

我本来想不通char s[5]="while";为什么是错的,直到我想起来字符串后面跟了个'\0'....

全部评论

相关推荐

Rac000n:淘天-客户运营部-AI研发工程师,智能客服方向,暑期实习招聘,欢迎联系
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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