C中的EASY任务,使用函数绘制ascii矩形

I have a working program to draw rectangles using "*" characters and I need to transform it so that it uses two functions and calls them, one function draws the top and bottom layer all from "*" and second function that draws the layers (rows) between, so it starts with "*", makes a few spaces and finishes with "*" The working program without multiple functions is down below. Please if you could at least send me on the right path, I tried everything I found :(

#include <stdio.h>

int main(void)

{
    int rows, columns, x, y;

while(1)
{
    printf("zadejte pocet radku: ");
    scanf("%d", &rows);
    if (rows<=1)
        continue;
    printf("zadejte pocet sloupcu: ");
        scanf("%d", &columns);
    if (columns<=1)
        continue;
    break;
}

for (x = 0; x < rows; x++) 
{   printf("\n");
    for (y = 0; y < columns; y++) 
    {
        if (x == 0 || x == rows - 1)            
        {
            if (y == 0)  
            printf("*");
            if (y == columns - 1)
            printf("*");
            else
            printf("*");
        }

        else
        {
            if (y == 0)  
            printf("*");
            if (y == columns - 1)
            printf("*");
            else
            printf(" ");
        }   
    }
    }    
return 0;
} 

评论