编写程序:在屏幕上打印杨辉三角 程序代码如下: #include # define LINE 10 int main() { int arr[LINE][LINE] = {0}; int i = 0; int j = 0; for (i = 0; i < LINE; i++) { arr[i][0] = 1; arr[i][i] = 1; } for (i = 2; i < LINE; i++) { for (j = 1; j < i; j++) { arr[i][j] = arr[i-1][j-1] + arr[i-1][j]; } } for (i = 0; i < LINE; i++) { for (j = 0; j < (2 * LINE - 2 * i); j++) { printf(" "); } for (j = 0; j <= i; j++) { printf("%4d",arr[i][j]); } printf("\n"); } return 0; } 程序运行结果如下: