int main() {
int i = 0;
int n = 0;
int travel = 0;
for (i = 1; i <= 9; i++) {
for (n = 1; n <= i; n++) {
travel = i * n;
printf("%d*%d=%-2d ", i, n, travel);
}
printf("\n");
}
return 0;
}
此处:
printf("%d*%d=%-2d ",i,n,travel);
用-2d是为了让代码输出乘法表的时候数字左对齐,看着更加工整.