Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void PrintAndCenterRectangle(int height, int width, char symbol);
- int GetStrLength(char[]);
- int main() {
- PrintAndCenterRectangle(15, 40, '*');
- }
- void PrintAndCenterRectangle(int height, int width, char symbol) {
- int emptySpaceForAbove = (25 - height) / 2;
- int emptySpaceForTheLeft = (80 - width) / 2;
- for (int i = 0; i < emptySpaceForAbove; i++)
- {
- cout << "\r\n";
- }
- for (int i = 0; i < height; i++)
- {
- for (int i = 0; i < emptySpaceForTheLeft; i++)
- {
- cout << ' ';
- }
- for (int i = 0; i < width; i++)
- {
- cout << symbol;
- }
- cout << "\r\n";
- }
- for (int i = 0; i < emptySpaceForAbove; i++)
- {
- cout << "\r\n";
- }
- }
- int GetStrLength(char arr[]) {
- int counter = 0;
- while (arr[counter] != '\0')
- counter++;
- return counter;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement