提交时间:2023-02-07 20:50:22

运行 ID: 7806

#include<iostream> using namespace std; int main(){ int n, g, s, b, q, total=0; cin >> n; for (int i=1; i<=n; i++){ g = i%10; s = (i/10)%10; b = (i/100)%10; q = i/1000; if (g == 1){ total += 1; } if (s == 1){ total += 1; } if (b == 1){ total += 1; } if (q == 1){ total += 1; } } if (n == 10000){ total += 1; } cout << total; return 0; }