mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-07 18:06:58 +08:00
Upload via code
This commit is contained in:
30
FZOI/数位递增数.cpp
Normal file
30
FZOI/数位递增数.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool isIncreasingNumber(int n) {
|
||||
string num = to_string(n);
|
||||
for (int i = 0; i < num.size() - 1; i++) {
|
||||
if (num[i] > num[i + 1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
|
||||
int count = 0;
|
||||
for (int i = 10; i <= n; i++) {
|
||||
if (isIncreasingNumber(i)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
cout << count << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user