5.输出杨辉三角形
include <stdio.h>
void main() {
int i, j, n, a100 = {0};
scanf("%d", &n);
for (i = 0; i < n; i++) {
ai = 1;
}
for (i = 1; i < n; i++) {
for (j = 1; j <= i; j++) {
ai = ai - 1 + ai - 1;
}
}
for (i = 0; i < n; i++) {
for (j = 0; j <= i; j++) {
printf("%-4d", ai);
}
printf("\n");
}
}
6.输出数字金字塔
include <stdio.h>
void main() {
int i, j;
for (i = 1; i <= 9; i++) {
for (j = 9; j > i; j--)
printf(" ");
for (j = 1; j <= i; j++)
printf("%c", 48 + j);
for (j = i - 1; j >= 1; j--)
printf("%c", 48 + j);
if (i != 9)
printf("\n");
}
}
7.打印乘法口诀表。
include <stdio.h>
void main() {
int i, j;
for (i = 1; i <= 9; i++) {
for (j = 1; j <= i; j++)
printf("%d %d = %-5d", i, j, i j);
if (i != 9)
printf("\n");
}
}