The parameters, draw the rectangle.

Description questions
The parameters, draw the rectangle.
Input Format
Input line, includes four parameters: the first two parameters are integers, sequentially rectangles representing height and width (not less than three rows high more than 10 rows and the width of not less than 10 not more than 5); a third parameter is a character, for drawing a rectangle representing the symbol; the fourth parameter is a hollow or 0,0, 1 represents a solid.
Output Format
Draw graphics output.
Sample input
7 7 @ 0
Sample Output
@@@@@@@
@     @
@     @
@     @
@     @
@     @
@@@@@@@
#include <stdio.h>
int main()
{
    int h,d,x,i,j;
    char a;
    while(scanf("%d %d %c %d",&h,&d,&a,&x)!=EOF)
    {
        if(x==1)
        {
            for(i=1;i<=h;i++)
            {
                for(j=1;j<=d;j++){
                    printf("%c",a);
                }
                    printf("\n");
            }
        }
        if(x==0){
            for(i=1;i<=h;i++){
                if(i==1||i==h){
                    for(j=1;j<=d;j++){
                        printf("%c",a);
                    }
                    printf("\n");
                }
                else{
                    for(j=1;j<=d;j++){
                    if(j==1||j==d){
                        printf("%c",a);
                    }
                    else{
                        printf(" ");
                    }
                }
                    printf("\n");
                }
            }
        }
    }
    return 0;
}

Published 32 original articles · won praise 9 · views 70000 +

Guess you like

Origin blog.csdn.net/yi__cao/article/details/78513830