题目来源:码蹄集
https://matiji.net/exam/brushquestion/430/778/B3FCFEC101BD05189BB74D522E019504
参考程序:
#include <iostream>
using namespace std;
bool ishuiwen(int x) {
if(x < 0 || (x>0 && x%10 == 0))
return false;
int c = 0;
while(x>c) {
c = c*10 + x%10;
x /= 10;
}
return c == x || x == c/10;
}
int main() {
int n;
cin >> n;
int t;
int cnt = 0;
for (int i = 1; i < n; i++) {
if (ishuiwen(i)) {
cnt++;
}
}
cout << cnt;
return 0;
}