测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A46406. 画矩形

填空题 容易

题目描述

画矩形

题目描述

根据参数,画出矩形。

时间限制:1000

内存限制:65536

输入

输入一行,包括四个参数:前两个参数为整数,依次代表矩形的高和宽(高不少

于 3 行不多于 10 行,宽不少于 5 列不多于 10 列);第三个参数是一个字符,

表示用来画图的矩形符号;第四个参数为 1 或 0,0 代表空心,1 代表实心。

输出

输出画出的图形。

样例输入

7 7 @ 0

样例输出

参考答案

#include<bits/stdc++.h> using namespace std; int main(){ int height,width,flag; char c; cin>>height>>width>>c>>flag; if(flag==0){ for(int i=1;i<=width;i++){ cout<<c; } cout<<endl; for(int i=1;i<=height-2;i++){ cout<<c; for(int i=1;i<=width-2;i++){ cout<<" "; } cout<<c; cout<<endl; } for(int i=1;i<=width;i++){ cout<<c; } } if(flag==1){ for(int i=1;i<=height;i++){ for(int j=1;j<=width;j++){ cout<<c; } cout<<endl; } } return 0; }
上一题 下一题