Advertisement
Felanpro

drawGenericRectangle at coordinate

Mar 16th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int width = 50;
  7. int height = 30;
  8.  
  9. void drawGenericRectangle(int positionX, int positionY)
  10. {
  11.     int rectangleX[10];
  12.     int rectangleY[5];
  13.  
  14.     for (int c = 0; c < 10; c++)
  15.     {
  16.         rectangleX[c] = positionX + c;
  17.     }
  18.  
  19.     for (int p = 0; p < 5; p++)
  20.     {
  21.         rectangleY[p] = positionY + p;
  22.     }
  23.  
  24.     bool flag = false;
  25.  
  26.     for (int y = 0; y < height; y++)
  27.     {
  28.         for (int x = 0; x < width; x++)
  29.         {
  30.             flag = false;
  31.             for (int w = 0; w < 5; w++)
  32.             {
  33.                 if (y == rectangleY[w])
  34.                 {
  35.                     for (int d = 0; d < 10; d++)
  36.                     {
  37.                         if (x == rectangleX[d])
  38.                         {
  39.                             flag = true;
  40.                             cout << "#";
  41.                         }
  42.                     }
  43.                 }
  44.             }
  45.             if (flag == false)
  46.                 cout << " ";
  47.         }
  48.         cout << endl;
  49.     }
  50. }
  51.  
  52. int main()
  53. {
  54.     drawGenericRectangle(10, 4);
  55.  
  56.     int pause; cin >> pause;
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement