字符串与数字之间的转换,具体见代码
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
scanf("%d",&n);
int sum = 0;
for (int i = 1; i <= n; ++i) {
string s = to_string(i);
if (s.find('2') != string::npos || s.find('0') != string::npos || s.find('1') != string::npos || s.find('9') != string::npos){
sum += stoi(s);
}
}
printf("%d\n",sum);
return 0;
}
0 回复
0 转发
0 喜欢
0 阅读



