1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <iostream> using namespace std; bool han(int n) { if (n < 100) return true; int a = n % 10; int b = n / 10 % 10; int c = n / 100; if (a – b == b – c) return true; return false; } int main(void) { int N, count = 0; cin >> N; for (int i = 1; i <= N; i++) { if (han(i)) count++; } cout << count; } | cs |