用C语言的for循环,打印九九乘法表
C语言:
#include <stdio.h>
int main(void)
{
int row, col;
for (row = 1; row <= 9; row++)
{
for (col = 1; col <= row; col++)
{
printf("%d * %d = %-2d ", col, row, row * col);
}
putchar('\n');
}
return 0;
}
运行结果:
1 * 1 = 1
1 * 2 = 2 2 * 2 = 4
1 * 3 = 3 2 * 3 = 6 3 * 3 = 9
1 * 4 = 4 2 * 4 = 8 3 * 4 = 12 4 * 4 = 16
1 * 5 = 5 2 * 5 = 10 3 * 5 = 15 4 * 5 = 20 5 * 5 = 25