主要是用for循环来写九九乘法表
1.左下角
#include <stdio.h>int main(){int i, j;for (i = 1; i < 10; i++){for (j = 1; j <= i; j++){printf("%d*%d=%-3d ", j, i, i * j);}printf("\n");}return 0;}
2.等腰三角形
#include <stdio.h>int main(){int a = 0, b = 0, c = 0;for (a = 9; a >= 1; a--){for (c = 0; c <= (8 - a) * 4; c++){printf(" ");}for (b = 1; b <= a; b++)printf("%d*%d=%2d ", a, b, a * b);printf("\n\n");}return 0;}
3.左上角
#include <stdio.h>int main(){int i = 0, j = 0;for (i = 9; i >= 1; i--){for (j = 1; j <= i; j++)printf("%d*%d=%-3d ", i, j, i * j);printf("\n");}return 0;}
4.右上角
#include <stdio.h>int main(){int i, j;for (i = 9; i > 0; i--){for (j = 9; j > 0; j--){if (i < j)printf("\t");elseprintf("%d*%d=%2d ", j, i, i * j);}printf("\n");}return 0;}
5.右下角
#include <stdio.h>int main(){int i = 0, j = 0;for (i = 1; i < 10; i++){for (j = 9; j > 0; j--){if (i >= j)printf("%d*%d=%-3d ", i, j, i * j);elseprintf("\t");}printf("\n");}return 0;}
如果觉得《C语言编写九九乘法表 实现不同三角形形状表格输出》对你有帮助,请点赞、收藏,并留下你的观点哦!