Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
4355 | A班-过懿萱 | 数1的个数 | C++ | 运行超时 | 0 | 1000 MS | 248 KB | 291 | 2025-01-11 11:33:39 |
#include <bits/stdc++.h> using namespace std; int main() { int n,count = 0; cin>>n; for(int i = 1;i <= n;i++) { int temp = i; while(temp != 0) { int p = n % 10; if (p == 1) { count++; } temp = n / 10; } } cout<<count<<endl; return 0; }