这是题解代码:
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
long long m;
int k,cnt3 = 0;
cin>>m>>k;
while(m){
if(m % 10 == 3)++cnt3;
m /= 10;
}
if(cnt3 == k)cout << "YES";
else cout << "NO";
return 0;
}
这是我的代码:
#include <bits/stdc++.h>
using namespace std;
long long sum=0;
int cf(int x){
while(x){
if(x%10==3)sum++;
x/=10;
}
}
int main()
{
long long n,k;
cin>>n>>k;
cf(n);
if(sum==k)cout<<"YES";
else cout<<"NO";
return 0;
}
有什么区别吗???