#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <math.h> #define MAX 8 int main() { int a[MAX][MAX] = { 0 }; for (int i = 0; i < MAX; i++) { a[i][0] = 1; a[i][i] = 1; if (i>=2) for (int j = 1; j < i; j++) a[i][j] = a[i - 1][j - 1] + a[i - 1][j]; } for (int i = 0; i < MAX; i++) { for (int j = 0; j < MAX; j++) if (a[i][j] != 0) printf("%5d", a[i][j]); printf("\n"); } system("pause"); return 0; }
原文地址:https://www.cnblogs.com/ssyfj/p/9390128.html
时间: 2024-10-13 21:19:31