qwq!!!
查看原帖
qwq!!!
1003721
shb20111113楼主2023/7/27 22:50

这是题解代码:

#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);
	//cout<<sum<<endl;
	if(sum==k)cout<<"YES";
	else cout<<"NO"; 
	return 0;
}

有什么区别吗???

2023/7/27 22:50
加载中...