求解:编的输出九九表的程序着实不知哪里出错了,烦请看下~
编程输出如下形式的九九表。1 2 3 4 5 6 7 8 9
----------------------------------------------------------
1 1 2 3 4 5 6 7 8 9
2 4 6 8 10 12 14 16 18
3 9 12 15 18 21 24 27
4 16 20 24 28 32 36
5 25 30 35 40 45
6 36 42 48 54
7 49 56 63
8 64 72
9 81
#include<stdio.h>
void main()
{
printf(" 1 2 3 4 5 6 7 8 9");
printf("\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n");
int yd[9][10] = { 0 };
int i, j;
for (i = 0; i < 9; i++)
{
yd[i][0] = i + 1;
for (j = i+1; j < 10; j++)
{
yd[i][j] = (i + 1)*(j);
}
}
for (i = 0; i < 9; i++)
{
for (j = 0; j < 10; j++)
if (yd[i][j] != 0)
{
if (yd[i][j] < 10)
{
printf(" ");
printf("%d", yd[i][j]);
printf(" ");
}
else
{
printf("%d", yd[i][j]);
printf(" ");
}
}
else
printf(" ");
printf("\n");
}
}