Advertisement
TheLegend12

Untitled

Sep 2nd, 2023
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. using namespace std;
  5.  
  6. inline int calculateLeftSpaces(int numberOfLevels, int levelIndex) {
  7. return 7 + (6 * (numberOfLevels - 1 - levelIndex));
  8. }
  9.  
  10.  
  11. int main() {
  12. int numberOfLevels;
  13. int choice;
  14. // The menu output. Don't modify this, so that it outputs exactly as expected
  15. cout << "Program 1: Step Pyramids" << endl;
  16. cout << "Which option would you like?" << endl;
  17. cout << " 1. Display original graphic" << endl;
  18. cout << " 2. Display Step Pyramid" << endl;
  19. cout << "Your choice: ";
  20. cin >> choice;
  21.  
  22. if (choice == 1){
  23. cout << "How tall do you want your stick figure? (size changes the number of vertical lines)";
  24. }
  25.  
  26. if (choice == 2){
  27. cout << "How many levels should be in the step pyramid? ";
  28. cin >> numberOfLevels;
  29. int topOfPyramid = calculateLeftSpaces(numberOfLevels, 0);
  30. cout << setw(topOfPyramid + 6) << " _______" << endl;
  31. cout << setw(topOfPyramid + 6) <<" |_______|" << endl;
  32. cout << setw(topOfPyramid + 6) <<" | ___ |" << endl;
  33. cout << setw(topOfPyramid + 8) <<"__|__[_]__|__" << endl;
  34.  
  35. for (int i = 1; i <= numberOfLevels; i++){
  36. int numberOfLeftSideSpaces = calculateLeftSpaces(numberOfLevels, i);
  37. int spacesToStairs = 4 + 6 * (i - 1);
  38. cout << setw(numberOfLeftSideSpaces + 1) << "/" << setw(spacesToStairs + 5) << "|===|" << setw(spacesToStairs + 1) << "\\" << endl;
  39. cout << setw(numberOfLeftSideSpaces) << "/" << setw(spacesToStairs + 6) << "|===|" << setw(spacesToStairs + 2) << "\\" << endl;
  40. if (i != numberOfLevels){
  41. cout << setw(numberOfLeftSideSpaces - 4) << "+" << setfill('+') << setw(spacesToStairs+10) << "|===|" ;
  42. for(int i=0;i<spacesToStairs+6;i++) cout << "+";
  43. cout << setfill(' ')<< endl;
  44. }
  45. }
  46. }
  47.  
  48.  
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement