题解 | 游游的数字圈
游游的数字圈
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, 最后输出答案