From e028f440205c672ef462f7118f673a1f68b059e6 Mon Sep 17 00:00:00 2001 From: Misha Date: Thu, 18 Sep 2025 19:47:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20rectangle.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rectangle.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 rectangle.cpp diff --git a/rectangle.cpp b/rectangle.cpp new file mode 100644 index 0000000..4f9c8c1 --- /dev/null +++ b/rectangle.cpp @@ -0,0 +1,37 @@ +#include + +using namespace std; + +void drawRectangle(int h, int w, char s = '*') { + if (h <= 0 || w <= 0) { + cout << "Помилка: висота та ширина повинні бути додатними числами!" << endl; + return; + } + + for (int i = 0; i < h; ++i) { + for (int j = 0; j < w; ++j) { + cout << s; + } + cout << endl; + } +} + +int main() { + + setlocale(0, ""); + cout << "=== Приклади малювання прямокутників ===" << endl; + + cout << "\nПрямокутник 5x10 зі зірочками (за замовчуванням):" << endl; + drawRectangle(5, 10); + + cout << "\nПрямокутник 3x8 з символом '#' :" << endl; + drawRectangle(3, 8, '#'); + + cout << "\nПрямокутник 4x12 з символом '@' :" << endl; + drawRectangle(4, 12, '@'); + + cout << "\nПрямокутник 2x6 з символом '+' :" << endl; + drawRectangle(2, 6, '+'); + + return 0; +} \ No newline at end of file