PTA: Print ninety-nine formulas table (10 points) (C language)

Here is a complete list of lower triangular ninety-nine formulas:

11=1
1
2=2 22=4
1
3=3 23=6 33=9
14=4 24=8 34=12 44=16
15=5 25=10 35=15 45=20 55=25
1
6=6 26=12 36=18 46=24 56=30 66=36
1
7=7 27=14 37=21 47=28 57=35 67=42 77=49
18=8 28=16 38=24 48=32 58=40 68=48 78=56 88=64
19=9 29=18 39=27 49=36 59=45 69=54 79=63 89=72 9*9=81

The title requirements for any given a positive integer N, the output from one of 1 to N N partial formulas table.

Input format:
Enter a given positive integer N (1≤N≤9) in a row.

Output format:
output lower triangular portion formulas N * N table, wherein the righthand side of the figure represents 4, left-justified.

Sample input:
4

Output Sample:
. 1 1 = 1
. 1
2 = 22 2 = 4
. 1
= 3 2 3 =. 3. 6 3 = 9
. 1 4 = 2. 4 4 =. 3. 8 4 =. 4 12 is 4 = 16

#include <stdio.h>

int main()
{
    int N;
    scanf("%d", &N);
    int i, n;
    for (n = 1; n <= N; n++)
    {
        for (i = 1; i <= n; i++)
        {
            printf("%d*%d=%-4d", i, n, n*i);
        }
        printf("\n");
    }
    return 0;
}
Published 58 original articles · won praise 21 · views 603

Guess you like

Origin blog.csdn.net/qq_45624989/article/details/105399604