[悬关] 做法求助
查看原帖
[悬关] 做法求助
776668
Gaogao2011楼主2023/4/30 21:14

在网上搜到了题解,代码是这样的

#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 函数没有看懂。求大佬解释一下。

2023/4/30 21:14
加载中...