AC日记——画矩形 1.5 42

42:画矩形

总时间限制: 
1000ms
 
内存限制: 
65536kB
描述

根据参数,画出矩形。

输入
输入一行,包括四个参数:前两个参数为整数,依次代表矩形的高和宽(高不少于3行不多于10行,宽不少于5列不多于10列);第三个参数是一个字符,表示用来画图的矩形符号;第四个参数为1或0,0代表空心,1代表实心。
输出
输出画出的图形。
样例输入
7 7 @ 0
样例输出
@@@@@@@
@     @
@     @
@     @
@     @
@     @
@@@@@@@

思路:

  模拟;

来,上代码:

#include<cstdio>
#include<iostream>

using namespace std;

int h,w,if_;

char ch;

int main()
{
    cin>>h>>w>>ch>>if_;
    for(int i=1;i<=w;i++) cout<<ch;
    cout<<endl;
    for(int i=2;i<h;i++)
    {
        cout<<ch;
        for(int j=2;j<w;j++)
        {
            if(if_) cout<<ch;
            else cout<<' ';
        }
        cout<<ch<<endl;
    }
    for(int i=1;i<=w;i++) cout<<ch;
    cout<<endl;
    return 0;
}
原文地址:https://www.cnblogs.com/IUUUUUUUskyyy/p/6154831.html