Description
九九乘法表是数学学习的基础,今天我们就来看看乘法表的相关问题。《九九乘法歌诀》,又常称为“小九九”,如下图所示。你的任务是写一个程序,对于给定的一个正整数 n ,输出“九九乘法表”的前 n 行。例如,输入 n 为 9,你的程序的输出将为下图:
Input
Comprising a plurality of sets of test data input, an EOF end. Each test contains only a positive integer n (0 <n <10).
Output
For each test case, the output map "multiplication table" shown in the first n rows.
Sample
Input
2
3
Output
11=1
12=2 22=4
11=1
12=2 22=4
13=3 23=6 3*3=9
Hint
You must use a for loop, if your code appears for example
if(n == 1) printf(“1*1=1\n”);
if(n == 2) printf(“11=1\n12=2 2*2=4\n”);
Or similar statements, this question does not score points.
The main question is to find the relationship between the line and two multipliers
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n,i,j;
while(scanf("%d",&n)!=EOF)
{
for(i=1; i<=n; i++)
{
for(j=1; j<=i; j++)
{
if(j==1)
{
printf("%d*%d=%d",j,i,j*i);
//第二个乘数就是行数,第一个乘数是由“1”递加到“行数”,最后是结果;
}
if(j!=1)
printf(" %d*%d=%d",j,i,j*i);
}
printf("\n");
}
}
return 0;
}