/*编程打印直角杨辉三角形
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
*/
#include <stdio.h> int main(int argc, const char * argv[]) { int a[6][6] = {0}; for (int i = 0; i < 6; i++) { a[i][0] = 1; a[i][i] = 1; } for (int i = 0; i < 5; i++) { for (int j = 0 ;j < 5 ; j++) { a[i+1][j+1] = a[i][j] + a[i][j+1]; } } for (int i = 0; i < 6; i++) { for (int j = 0; j <= i; j++) { printf("%i ",a[i][j]); } printf(" "); } return 0; }