Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
30324 | zhouhuanyu 玙静 | 数1的个数 | C++ | 通过 | 0 MS | 244 KB | 246 | 2023-11-06 20:31:06 |
#include <bits/stdc++.h> using namespace std; int main(){ int n, cnt = 0; cin >> n; for (int i = 1; i <= n; i++){ int t = i; while(t != 0){ if(t % 10 == 1){ cnt ++; } t /= 10; } } cout << cnt; return 0; }