杭电2032 杨辉三角
作者:互联网
C
#include "stdio.h"
int main() {
int num;
while (scanf("%d", &num) != EOF) {
int a[num][num];
for (int i = 0; i < num; ++i) {
for (int j = 0; j <= i; ++j) {
if (i == j || j == 0) {
a[i][j] = 1;
} else {
a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
}
}
}
for (int i= 0; i < num; ++i) {
for (int j = 0; j <= i; ++j) {
if (!j) {
printf("%d", a[i][j]);
} else {
printf(" %d", a[i][j]);
}
}
printf("\n");
}
printf("\n");
}
return 0;
}
标签:int,else,杭电,++,num,2032,printf,杨辉三角 来源: https://blog.csdn.net/Justodiante/article/details/113828767