-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrectangles.cpp
More file actions
45 lines (38 loc) · 986 Bytes
/
rectangles.cpp
File metadata and controls
45 lines (38 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* TODO: write a program that reads two integers n,m and draws an n x m
* hollow rectangle of '*' characters. E.g., on input n=4,m=7, the result
* would look like this: */
// * * * * * * *
// * *
// * *
// * * * * * * *
/* NOTE: place spaces between the characters to compensate for the fact that
* most terminal fonts are taller than they are wide.
* */
#include<iostream>
using namespace std;
int main() {
int row, column;
cout << "Please enter the amount of rows: \n";
cin >> row;
cout << "Please enter the amount of columns: \n";
cin >> column;
for (int i = 0; i < row; i++) {
for (int j = 0; j < column; j++) {
//Print a full row for the first and last row
if (i == 0 || i == row - 1) {
cout << "* ";
}
//Print a hollow row for the rest
else {
if (j == 0 || j == column - 1) {
cout << "* ";
}
else {
cout << " ";
}
}
}
cout << "\n";
}
return 0;
}