Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h> // для time()
- #include <stdlib.h> // для rand()
- using namespace std;
- void print_rectangle(int H, int W) { // H - высота, W - ширина
- for (int i = 0; i < H; i++) {
- for (int j = 0; j < W; j++) {
- if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
- cout << '*';
- }
- else {
- cout << " ";
- }
- }
- cout << endl;
- }
- }
- int main() {
- setlocale(LC_ALL, "ru");
- int N, K;
- cout << "Введите ширину: ";
- cin >> K;
- cout << "Введите высоту: ";
- cin >> N;
- print_rectangle(N, K);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement