40求助
查看原帖
40求助
1071426
shx2011楼主2024/8/28 14:12

求调

555不知道为啥就WA了

#include<bits/stdc++.h>
using namespace std;
int n,ans=1,l,r;
int a[100010];
bool cw(int n){
	int t;
	while(n!=0){
		t=n%10;
		if(t==2) return true;
		n/=10;
	}
	
	return false;
}
int main(){
	cin>>l>>r;
	for(int i=l;i<=r;i++){
		if(cw(i)) ans++;
	}
	cout<<ans;
	return 0;
}

2024/8/28 14:12
加载中...