Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
7806 董语涵 数1的个数 C++ 通过 0 MS 252 KB 417 2023-02-07 20:50:22

Tests(1/1):


#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; }


测评信息: