使用了to_string方法进行字符串按位比对,理论上不可能错呀?
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;char x;
int count_x=0;
cin>>n>>x;
for(int i=0;i<=n;i++){
string s=to_string(i);
for (int j=0;j<s.size();j++){
if (s[j]==x) count_x++;
}}
cout<<count_x;
return 0;
}