Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
7846 | 侯宜辰 | 各个位数之和 | C++ | Compile Error | 0 MS | 0 KB | 232 | 2025-05-24 11:11:56 |
#include <iostream> using namespace std; int main() { int a s=0 cin >>a; if (a< 0) { a= -a; } for (; a != 0; a /= 10) { s += a % 10; } cout << s << endl; return 0; }
Main.cc: In function 'int main()': Main.cc:5:11: error: expected initializer before 's' int a s=0 ^ Main.cc:7:9: error: 'a' was not declared in this scope if (a< 0) { ^ Main.cc:10:12: error: 'a' was not declared in this scope for (; a != 0; a /= 10) { ^ Main.cc:11:9: error: 's' was not declared in this scope s += a % 10; ^ Main.cc:14:13: error: 's' was not declared in this scope cout << s << endl; ^