Created
February 3, 2017 05:05
-
-
Save amanat361/272a4eaf3377ce4544592464b303068a to your computer and use it in GitHub Desktop.
Clean version of main2.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Samin Amanat | |
| //Necessary things | |
| #include <iostream> | |
| #include <string> | |
| #include <cstdlib> | |
| using namespace std; | |
| int main() { | |
| //declaring variables | |
| int rows; | |
| int menu; | |
| string phrase; | |
| do //all the code below... | |
| { | |
| //menu | |
| cout << "\n---MENU---\n\n 1. Run program\n 2. Quit :(\n\n----------\n\nWhat would you like to do (1-2): "; | |
| cin >> menu; | |
| //option to quit | |
| if (menu == 2) { | |
| return 0; | |
| } | |
| //if the user does not provide proper input | |
| else if (menu != 1) { | |
| cout << "\nNext time, please only enter either a '1' or a '2'\n\n"; | |
| system("pause"); | |
| return 0; | |
| } | |
| //the actual code for the program | |
| else { | |
| //user choses what phrase is to be repeated | |
| cout << "\nEnter a phrase (code only works with one word phrases for now): "; | |
| cin >> phrase; | |
| //how many rows (self explanatory) | |
| cout << "\nEnter the number of rows (must be at least 2): "; | |
| cin >> rows; | |
| //some good old spacing | |
| cout << "\n"; | |
| //code for the rows and columns | |
| while (rows < 2); | |
| for (int curr_row = 0; curr_row < rows; curr_row++) | |
| { | |
| for (int curr_col = 0; curr_col < curr_row; curr_col++) | |
| cout << " "; | |
| cout << phrase << endl; | |
| } | |
| //peace of mind :) | |
| cout << "\n"; | |
| } | |
| //so that the code does not exit for no good reason | |
| system("pause"); | |
| } | |
| //to redo the code if the user wants to | |
| while (true); | |
| //to terminate when the user is satisfied | |
| return 0; | |
| } | |
| //end of code :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment