题解 | 游游的数字圈

游游的数字圈

https://www.nowcoder.com/practice/16eafa41a4a242b8870cb2c5420ae089

#include <bits/stdc++.h>

using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0);
typedef long long LL;

//const int N=;

int main()
{
    IOS
    string s;
    cin>>s;
    int ans=0;
    for(auto it: s){
        if(it=='0'||it=='6'||it=='9') ans++;
        else if(it=='8') ans+=2;
    }
    cout<<ans;
    return 0;
}

if判断是否为那几个字符即可,注意8是+=2, 最后输出答案

#牛客春招刷题训练营#

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务