删
本帖最后由 G`J 于 2020-12-1 22:43 编辑。 i = 1
while i <= 9:
j = 9
while j >= i:
print(j, "*", i, "=", j * i, end=' ')
j -= 1
print()
i += 1 for i in range(1,10):
for c in range(1,10):
print(i,"*",c,'=',i*c)
// 输出乘法口诀表
#include<stdio.h>
void main()
{
int i,j,k;
for(i = 1;i < 10;i++)
{
for(j =1;j < 10;j++)
{
if(i >= j)
{
k = i * j;
printf("%dx%d=%-3d",j,i,k); /* -3d表示左对齐,占3位 */
}
}
printf("\n");
}
} for i in range(1,10):
for j in range(1,i+1):
print(i,'x',j,'=',i*j,end=' ')
print('\n') 本帖最后由 昨非 于 2020-11-25 08:57 编辑
风过无痕1989 发表于 2020-11-25 00:24
老哥,这是python区的
昨非 发表于 2020-11-25 08:55
老哥,这是python区的
又看错了
参考代码:
for i in range(1,10):
for j in range(0,10-i):
print(j+1,'x',j+i,'=',f'{(j+1)*(j+i):<4}',end='')
print()
打印结果:
1 x 1 = 1 2 x 2 = 4 3 x 3 = 9 4 x 4 = 165 x 5 = 256 x 6 = 367 x 7 = 498 x 8 = 649 x 9 = 81
1 x 2 = 2 2 x 3 = 6 3 x 4 = 124 x 5 = 205 x 6 = 306 x 7 = 427 x 8 = 568 x 9 = 72
1 x 3 = 3 2 x 4 = 8 3 x 5 = 154 x 6 = 245 x 7 = 356 x 8 = 487 x 9 = 63
1 x 4 = 4 2 x 5 = 103 x 6 = 184 x 7 = 285 x 8 = 406 x 9 = 54
1 x 5 = 5 2 x 6 = 123 x 7 = 214 x 8 = 325 x 9 = 45
1 x 6 = 6 2 x 7 = 143 x 8 = 244 x 9 = 36
1 x 7 = 7 2 x 8 = 163 x 9 = 27
1 x 8 = 8 2 x 9 = 18
1 x 9 = 9
页:
[1]