九九乘法表

这边提供了两种格式可自行选择

#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 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;
}
发表评论

相关文章

==========================