#include using namespace std;

void drawRectangle(int height, int width, char symbol, int solid) { // 判断是否为实心矩形 if (solid == 1) { // 循环打印行 for (int i = 0; i < height; i++) { // 循环打印列 for (int j = 0; j < width; j++) { cout << symbol; } cout << endl; } } else { // 循环打印行 for (int i = 0; i < height; i++) { // 循环打印列 for (int j = 0; j < width; j++) { // 判断是否为矩形边缘 if (i == 0 || i == height - 1 || j == 0 || j == width - 1) { cout << symbol; } else { cout << " "; } } cout << endl; } } }

int main() { int height, width, solid; char symbol; cin >> height >> width >> symbol >> solid; drawRectangle(height, width, symbol, solid); return 0;

描述根据参数画出矩形。输入输入一行包括四个参数:前两个参数为整数依次代表矩形的高和宽高不少于3行不多于10行宽不少于5列不多于10列

原文地址: https://www.cveoy.top/t/topic/h2q9 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录