int main()
{
int i = 0;
int j = 0;
for ( i = 1; i <= 9; i++)
{
for (j = 1; j <= i; j++)
{
printf("%d*%d=%-2d ",i,j, i * j);
}
printf("\n");
}
return 0;
}
问题梳理:
1. j 应该是<=i,而不是<=9,否则会输出1*2=2;2*1=2等重复式子;
2. -2加在%和d之间,而不是之前
int main()
{
int i = 0;
int j = 0;
for ( i = 1; i <= 9; i++)
{
for (j = 1; j <= i; j++)
{
printf("%d*%d=%-2d ",i,j, i * j);
}
printf("\n");
}
return 0;
}
问题梳理:
1. j 应该是<=i,而不是<=9,否则会输出1*2=2;2*1=2等重复式子;
2. -2加在%和d之间,而不是之前