用C语言打印乘法表,在这个程序中使用的是For循环结构。
#include <stdio.h>
#include <stdlib.h>
int main() {
//a,b控制行或列
int a ;
int b ;
for (a=1; a <= 9; a++) {
for (b=1; b <= 9; b++)
//%2d 控制宽度为两个字符,且右对齐;如果改为 %-2d 则为左对齐
printf("%d*%d=%2d\t", a, b, a*b);
printf("\n");
}
system("pause");
return 0;
}
参考源码:http://c.biancheng.net/view/494.html