code.cpp 461 B

123456789101112131415
  1. /* Create a function that creates a box based on dimension n.
  2. */
  3. std::vector<std::string> makeBox(int n) {
  4. // n represents the height of the box and length
  5. std::vector<std::string> thebox;
  6. for (int i=0;i<n;i++){
  7. // creates an array of strings based on "n"
  8. thebox.push_back(std::string(n,'#'));
  9. // modify the middle rows by replacing the center characters
  10. if((i>0) && (i < (n-1))){
  11. thebox[i].replace (1, n-2, n-2, ' ');
  12. }
  13. }
  14. return thebox;
  15. }