#include<stdio.h> main() { int a[100][100]={0},i,j,k,n=10; int num; printf ( "input num:\n" ); /*输入打印的行数*/ scanf ( "%d",&num ); a[0][1]=1; /*确定第一行的初始值*/ for ( i=1; i<num; i++ ) { for ( j=1; j<=i+1; j++ ) { a[i][j]=a[i-1][j-1]+a[i-1][j];/*每一个值由这个数的肩上的两个值确定*/ } } for ( i=0; i<num; i++ ) { for ( k=0; k<n-i; k++ ) /*留出每行的空间*/ printf ( " " ); for ( j=1; j<=i+1; j++ ) { printf ( "%4d",a[i][j] ); } printf ( "\n" ); } }