Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
158843 陈襗葳 打印数字图形 C++ Compile Error 0 MS 0 KB 908 2026-08-22 17:53:38

Tests(0/0):


Code:

include <iostream> using namespace std; int main() { int n; while (cin >> n) //多组输入 { //上半部分(包含中间行) for(int i = 1; i <= n; i++) { //打印前置空格 for(int j = 1; j <= n - i; j++) cout << ' '; //升序 1~i for(int j = 1; j <= i; j++) cout << j; //降序 i-1 ~1 for(int j = i - 1; j >= 1; j--) cout << j; cout << endl; } //下半部分 for(int i = n - 1; i >= 1; i--) { for(int j = 1; j <= n - i; j++) cout << ' '; for(int j = 1; j <= i; j++) cout << j; for(int j = i - 1; j >= 1; j--) cout << j; cout << endl; } } return 0; }


Run Info:

Main.cc:1:1: error: 'include' does not name a type
 include 
 ^
Main.cc: In function 'int main()':
Main.cc:7:12: error: 'cin' was not declared in this scope
     while (cin >> n)   //多组输入
            ^
Main.cc:14:17: error: 'cout' was not declared in this scope
                 cout << ' ';
                 ^
Main.cc:17:17: error: 'cout' was not declared in this scope
                 cout << j;
                 ^
Main.cc:20:17: error: 'cout' was not declared in this scope
                 cout << j;
                 ^
Main.cc:21:13: error: 'cout' was not declared in this scope
             cout << endl;
             ^
Main.cc:21:21: error: 'endl' was not declared in this scope
             cout << endl;
                     ^
Main.cc:27:17: error: 'cout' was not declared in this scope
                 cout << ' ';
                 ^
Main.cc:29:17: error: 'cout' was not declared in this scope
                 cout << j;
                 ^
Main.cc:31:17: error: 'cout' was not declared in this scope
                 cout << j;
                 ^
Main.cc:32:13: error: 'cout' was not declared in this scope
             cout << endl;
             ^
Main.cc:32:21: error: 'endl' was not declared in this scope
             cout << endl;
                     ^