在网上搜到了题解,代码是这样的
#include <iostream>
#include <cstdio>
using namespace std;
int a, b, ans;
bool judge(int x) {
if (x < 10) return true;
while (x) {
if (x % 10 <= x / 10 % 10) return false;
x /= 10;
}
return true;
}
int main() {
scanf("%d%d", &a, &b);
for (int i = a; i <= b; i++) {
if (judge(i)) ans++;
}
printf("%d\n", ans);
return 0;
}
judge 函数没有看懂。求大佬解释一下。