编程输出九九乘法表倒三角(编写程序九九乘法表倒三角)

http://www.itjxue.com  2023-04-09 09:39  来源:未知  点击次数: 

如何用C语言写出一个九九乘法表,输出格式是倒三角形状,就是上面多下面少?

#include stdio.h

void main()

{

int i;

int j;

for (i = 1; i = 9; i++)

{

for (j = 1; j = i; j++)

{

printf("%-4d*%-4d=%-4d\n", j, i, j * i);

}

}

}

就这样吧,上三角的没见过,可以考虑换行,如果需要,再联系。

c语言输出九九乘法表(选择1为正三角,选择2为倒三角)

#include?stdio.h

int?main()

{

????int?n,i,j;

????scanf("%d",n);

????if(n?==?1)

????{

????????for(i?=?1;?i=9;?i?++)

????????{

????????????for(j?=?1;?j?=?i;?j?++)

????????????{

????????????????printf("%-2d?*?%-2d?=?%-4d",?i,?j,?i*j);

????????????}

????????????printf("\n");

????????}

????}

????else?if(n?==?2)

????{????

????????for(i?=?1;?i=9;?i?++)

????????{

????????????for(j?=?1;?j?=?10-i;?j?++)

????????????{

????????????????printf("%-2d?*?%-2d?=?%-4d",?i,?j,?i*j);

????????????}

????????????printf("\n");

????????}

????}

}

c语言编写九九乘法表 要成倒三角

#include stdio.h

int main(void)

{

int i;

int l;

int sum;

for (i = 1; i = 9; i ++)

{

for (l = 1; l = i; l ++)

{

sum = i * l;

printf("%d*%d=%-3d",l,i,sum);

}

printf("\n");

}

return 0;

}

(责任编辑:IT教学网)

更多