*Marco 4#8945

*Marco 4 (Editorial)

We draw a rectangular frame of n \times m as follows:

Algorithm Implementation

Read the input values and .

scanf("%d %d", &n, &m);

Output the first row – asterisks.

for (i = 0; i < m; i++)
    printf("*");
printf("\n");

Output n - 2 rows. In each row, output an asterisk, m - 2 spaces, and another asterisk, but only if m > 1.

for (i = 0; i < n - 2; i++)
{
    printf("*");
    for (j = 0; j < m - 2; j++)
        printf(" ");
    if (m > 1)
        printf("*");
    printf("\n");
}

Output the last row – asterisks. Output it only if n > 1.

if (n > 1)
{
    for (i = 0; i < m; i++)
        printf("*");
    printf("\n");
}