Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- using namespace std;
- int numberOfLeftSideSpaces;
- int spacesToStairs;
- // inline int calculateLeftSpaces(int numberOfLevels, int levelIndex) {
- // return 0;
- int main() {
- int numberOfLevels;
- int choice;
- // The menu output. Don't modify this, so that it outputs exactly as expected
- cout << "Program 1: Step Pyramids" << endl;
- cout << "Which option would you like?" << endl;
- cout << " 1. Display original graphic" << endl;
- cout << " 2. Display Step Pyramid" << endl;
- cout << "Your choice: ";
- cin >> choice;
- if (choice == 1){
- cout << "How tall do you want your stick figure? (size changes the number of vertical lines)";
- }
- if (choice == 2){
- cout << "How many levels should be in the step pyramid? ";
- cin >> numberOfLevels;
- // int topOfPyramid = calculateLeftSpaces(numberOfLevels, 0);
- if (numberOfLevels==0){ //2 + (levels - i) * 6--- this shouold be the formula
- // topOfPyramid += 2;
- cout << setw((numberOfLeftSideSpaces + spacesToStairs) + 10) << " _______" << endl;
- cout << setw(11) <<" |_______|" << endl;
- cout << setw(11) <<" | ___ |" << endl;
- cout << setw(13) <<"__|__[_]__|__" << endl;
- }
- else {
- cout << setw((numberOfLeftSideSpaces + spacesToStairs) + 10) << " _______" << endl;
- cout << setw(numberOfLeftSideSpaces + spacesToStairs) << " |_______|" << endl;
- cout << setw(11) <<" | ___ |" << endl;
- cout << setw(13) <<"__|__[_]__|__" << endl;
- for (int i = 1; i <= numberOfLevels; i++){
- numberOfLeftSideSpaces = 2 + (numberOfLevels - i) * 6;
- spacesToStairs = 4 + 6 * (i - 1);
- cout << setw(numberOfLeftSideSpaces + 1) << "/" << setw(spacesToStairs + 5) << "|===|" << setw(spacesToStairs + 1) << "\\" << endl;
- cout << setw(numberOfLeftSideSpaces) << "/" << setw(spacesToStairs + 6) << "|===|" << setw(spacesToStairs + 2) << "\\" << endl;
- if (i != numberOfLevels){
- cout << setw(numberOfLeftSideSpaces - 4) << "+" << setfill('+') << setw(spacesToStairs+10) << "|===|" ;
- for(int i=0;i<spacesToStairs+6;i++) cout << "+";
- cout << setfill(' ')<< endl;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement