Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. void PrintAndCenterRectangle(int height, int width, char symbol);
  6.  
  7. int GetStrLength(char[]);
  8.  
  9. int main() {
  10. PrintAndCenterRectangle(15, 40, '*');
  11. }
  12.  
  13. void PrintAndCenterRectangle(int height, int width, char symbol) {
  14. int emptySpaceForAbove = (25 - height) / 2;
  15. int emptySpaceForTheLeft = (80 - width) / 2;
  16.  
  17. for (int i = 0; i < emptySpaceForAbove; i++)
  18. {
  19. cout << "\r\n";
  20. }
  21.  
  22. for (int i = 0; i < height; i++)
  23. {
  24. for (int i = 0; i < emptySpaceForTheLeft; i++)
  25. {
  26. cout << ' ';
  27. }
  28.  
  29. for (int i = 0; i < width; i++)
  30. {
  31. cout << symbol;
  32. }
  33.  
  34. cout << "\r\n";
  35. }
  36.  
  37. for (int i = 0; i < emptySpaceForAbove; i++)
  38. {
  39. cout << "\r\n";
  40. }
  41.  
  42. }
  43.  
  44. int GetStrLength(char arr[]) {
  45. int counter = 0;
  46.  
  47. while (arr[counter] != '\0')
  48. counter++;
  49.  
  50. return counter;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement