这边提供了两种格式可自行选择
#include<stdio.h>
int main()
{
int n = 1;
int m = 1;
int z = 0;
for (n = 1;n <= 9;n++)
{
for (m = 1;m <= n;m++)
{
printf("%dX%d=%-2d ", m, n, m * n);
}
printf("\n"); //n还可用来控制换行
}
return 0;
}
上面这是第一种格式,下面是第二种格式
#include<stdio.h>标签:%-,九九乘法,int,2d,includeint,printf,格式 From: https://blog.51cto.com/u_15880518/5883466
int main()
{
int n = 1;
int m = 1;
int z = 0;
for (n = 1;n <= 9;n++)
{
for (m = 1;m <= 9;m++)
{
z = n * m;
printf("%dX%d=%-2d ", m, n, z);
if (m == 9)
{
printf("\n");
}
}
}
return 0;
}