You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
836 B

2 years ago
#include <bits/stdc++.h>
/*
11351024
n 11 n
*/
using namespace std;
int n, cnt;
bool iSDiZeng(int t) {
//哨兵
int x = 10; //这里定义x为10是为了便于将个位数的大小与t作比较
//个位数永远小于10
while (t) {
if (t % 10 > x) return false;
x = t % 10; // x一直在更新
t /= 10; // n分解出一个数便舍去一个数
}
return true;
}
int main() {
cin >> n;
for (int i = 11; i <= n; i++)
if (iSDiZeng(i)) cnt++;
cout << cnt << endl;
return 0;
}