Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
128353 梁敖铭 打印杨辉三角 C++ Compile Error 0 MS 0 KB 544 2025-08-15 22:11:02

Tests(0/0):


Code:

#include<stdio.h> int main() { int n; scanf("%d", &n); // 输入行数 intarr[n][n] = {0}; // 创建二维数组 for(introw = 0; row < n; row++) { for(intcolumn = 0; column <= row; column++) { if(column == 0 || column == row) { arr[row][column] = 1; // 首尾为1 } else { arr[row][column] = arr[row-1][column] + arr[row-1][column-1]; // 计算中间值 } printf("%d ", arr[row][column]); // 打印当前值 } printf("\n"); // 换行 }


Run Info:

Main.cc: In function 'int main()':
Main.cc:5:5: error: 'intarr' was not declared in this scope
     intarr[n][n] = {0}; // 创建二维数组
     ^
Main.cc:6:9: error: 'introw' was not declared in this scope
     for(introw = 0; row < n; row++) {
         ^
Main.cc:6:21: error: 'row' was not declared in this scope
     for(introw = 0; row < n; row++) {
                     ^
Main.cc:7:13: error: 'intcolumn' was not declared in this scope
         for(intcolumn = 0; column <= row; column++) {
             ^
Main.cc:7:28: error: 'column' was not declared in this scope
         for(intcolumn = 0; column <= row; column++) {
                            ^
Main.cc:9:13: error: 'arr' was not declared in this scope
             arr[row][column] = 1; // 首尾为1
             ^
Main.cc:11:13: error: 'arr' was not declared in this scope
             arr[row][column] = arr[row-1][column] + arr[row-1][column-1]; // 计算中间值
             ^
Main.cc:13:23: error: 'arr' was not declared in this scope
         printf("%d ", arr[row][column]); // 打印当前值
                       ^
Main.cc:16:1: error: expected '}' at end of input
 }
 ^
Main.cc:4:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n); // 输入行数
                    ^