| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 128354 | 梁敖铭 | 打印杨辉三角 | C++ | Compile Error | 0 MS | 0 KB | 768 | 2025-08-15 22:12:57 |
#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; 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"); // 换行 }
Main.cc: In function 'int main()':
Main.cc:10:5: error: 'intarr' was not declared in this scope
intarr[n][n] = {0}; // 创建二维数组
^
Main.cc:11:9: error: 'introw' was not declared in this scope
for(introw = 0; row < n; row++) {
^
Main.cc:11:21: error: 'row' was not declared in this scope
for(introw = 0; row < n; row++) {
^
Main.cc:12:13: error: 'intcolumn' was not declared in this scope
for(intcolumn = 0; column <= row; column++) {
^
Main.cc:12:28: error: 'column' was not declared in this scope
for(intcolumn = 0; column <= row; column++) {
^
Main.cc:14:13: error: 'arr' was not declared in this scope
arr[row][column] = 1; // 首尾为1
^
Main.cc:16:13: error: 'arr' was not declared in this scope
arr[row][column] = arr[row-1][column] + arr[row-1][column-1]; // 计算中间值
^
Main.cc:18:23: error: 'arr' was not declared in this scope
printf("%d ", arr[row][column]); // 打印当前值
^
Main.cc:21:1: error: expected '}' at end of input
}
^
Main.cc:9:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n); // 输入行数
^