#include // for cin and cout #include // for setw() and setfill() using namespace std; // so that we don't need to preface every cin and cout with std:: void printFirstTwoBuildingSection(int n, int startSpacing) { int start = n / 2, end = 0; if (n <= 2) { start = 0; } for (int i = 0; i < n; i++) { for (int j = 0; j < startSpacing; j++) { cout << " "; } cout << "|"; if (i < (n / 2)) { for (int k = 0; k < i; k++) { cout << " "; } cout << "\\"; for (int k = 0; k < start; k++) { cout << " "; } cout << "/"; start -= (n / 2); for (int k = 0; k < i; k++) { cout << " "; } cout << "|" << endl; } else { for (int k = n - i - 1; k > 0; k--) { cout << " "; } cout << "/"; for (int k = 0; k < end; k++) { cout << " "; } cout << "\\"; end += (n / 2); for (int k = n - i - 1; k > 0; k--) { cout << " "; } cout << "|" << endl; } } for (int j = 0; j < startSpacing; j++) { cout << " "; } cout << "/"; for (int i = 0; i < n; i++) { cout << "-"; } cout << "\\" << endl; } int main() { int menuOption = 0; cout << "Choose from among the following options:\n" << "1. Exit the program\n" << "2. Display building\n" << "Your choice -> "; cin >> menuOption; cout << endl; // Leave a blank line after getting the user input for the menu option. // See if exit was chosen if (menuOption == 1) { exit(0); } // Menu 2 if (menuOption == 2) { cout << " /\\ " << endl; cout << " || " << endl; cout << " || " << endl; cout << " -- " << endl; cout << " |++|" << endl; cout << " ====" << endl; printFirstTwoBuildingSection(2, 1); printFirstTwoBuildingSection(4, 0); } cout << endl; return 0; } #include // for cin and cout #include // for setw() and setfill() using namespace std; // so that we don't need to preface every cin and cout with std:: void printFirstTwoBuildingSection(int n, int startSpacing) { int start = n / 2, end = 0; if (n <= 2) { start = 0; } for (int i = 0; i < n; i++) { for (int j = 0; j < startSpacing; j++) { cout << " "; } cout << "|"; if (i < (n / 2)) { for (int k = 0; k < i; k++) { cout << " "; } cout << "\\"; for (int k = 0; k < start; k++) { cout << " "; } cout << "/"; start -= (n / 2); for (int k = 0; k < i; k++) { cout << " "; } cout << "|" << endl; } else { for (int k = n - i - 1; k > 0; k--) { cout << " "; } cout << "/"; for (int k = 0; k < end; k++) { cout << " "; } cout << "\\"; end += (n / 2); for (int k = n - i - 1; k > 0; k--) { cout << " "; } cout << "|" << endl; } } for (int j = 0; j < startSpacing; j++) { cout << " "; } cout << "/"; for (int i = 0; i < n; i++) { cout << "-"; } cout << "\\" << endl; } int main() { int menuOption = 0; cout << "Choose from among the following options:\n" << "1. Exit the program\n" << "2. Display building\n" << "Your choice -> "; cin >> menuOption; cout << endl; // Leave a blank line after getting the user input for the menu option. // See if exit was chosen if (menuOption == 1) { exit(0); } // Menu 2 if (menuOption == 2) { cout << " /\\ " << endl; cout << " || " << endl; cout << " || " << endl; cout << " -- " << endl; cout << " |++|" << endl; cout << " ====" << endl; printFirstTwoBuildingSection(2, 1); printFirstTwoBuildingSection(4, 0); } cout << endl; return 0; }
This is What i have so far.
#include <iostream> // for cin and cout
#include <iomanip> // for setw() and setfill()
using namespace std; // so that we don't need to preface every cin and cout with std::
void printFirstTwoBuildingSection(int n, int startSpacing)
{
int start = n / 2, end = 0;
if (n <= 2)
{
start = 0;
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < startSpacing; j++)
{
cout << " ";
}
cout << "|";
if (i < (n / 2))
{
for (int k = 0; k < i; k++)
{
cout << " ";
}
cout << "\\";
for (int k = 0; k < start; k++)
{
cout << " ";
}
cout << "/";
start -= (n / 2);
for (int k = 0; k < i; k++)
{
cout << " ";
}
cout << "|" << endl;
}
else
{
for (int k = n - i - 1; k > 0; k--)
{
cout << " ";
}
cout << "/";
for (int k = 0; k < end; k++)
{
cout << " ";
}
cout << "\\";
end += (n / 2);
for (int k = n - i - 1; k > 0; k--)
{
cout << " ";
}
cout << "|" << endl;
}
}
for (int j = 0; j < startSpacing; j++)
{
cout << " ";
}
cout << "/";
for (int i = 0; i < n; i++)
{
cout << "-";
}
cout << "\\" << endl;
}
int main()
{
int menuOption = 0;
cout << "Choose from among the following options:\n"
<< "1. Exit the program\n"
<< "2. Display building\n"
<< "Your choice -> ";
cin >> menuOption;
cout << endl; // Leave a blank line after getting the user input for the menu option.
// See if exit was chosen
if (menuOption == 1)
{
exit(0);
}
// Menu 2
if (menuOption == 2)
{
cout << " /\\ " << endl;
cout << " || " << endl;
cout << " || " << endl;
cout << " -- " << endl;
cout << " |++|" << endl;
cout << " ====" << endl;
printFirstTwoBuildingSection(2, 1);
printFirstTwoBuildingSection(4, 0);
}
cout << endl;
return 0;
}
#include <iostream> // for cin and cout
#include <iomanip> // for setw() and setfill()
using namespace std; // so that we don't need to preface every cin and cout with std::
void printFirstTwoBuildingSection(int n, int startSpacing)
{
int start = n / 2, end = 0;
if (n <= 2)
{
start = 0;
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < startSpacing; j++)
{
cout << " ";
}
cout << "|";
if (i < (n / 2))
{
for (int k = 0; k < i; k++)
{
cout << " ";
}
cout << "\\";
for (int k = 0; k < start; k++)
{
cout << " ";
}
cout << "/";
start -= (n / 2);
for (int k = 0; k < i; k++)
{
cout << " ";
}
cout << "|" << endl;
}
else
{
for (int k = n - i - 1; k > 0; k--)
{
cout << " ";
}
cout << "/";
for (int k = 0; k < end; k++)
{
cout << " ";
}
cout << "\\";
end += (n / 2);
for (int k = n - i - 1; k > 0; k--)
{
cout << " ";
}
cout << "|" << endl;
}
}
for (int j = 0; j < startSpacing; j++)
{
cout << " ";
}
cout << "/";
for (int i = 0; i < n; i++)
{
cout << "-";
}
cout << "\\" << endl;
}
int main()
{
int menuOption = 0;
cout << "Choose from among the following options:\n"
<< "1. Exit the program\n"
<< "2. Display building\n"
<< "Your choice -> ";
cin >> menuOption;
cout << endl; // Leave a blank line after getting the user input for the menu option.
// See if exit was chosen
if (menuOption == 1)
{
exit(0);
}
// Menu 2
if (menuOption == 2)
{
cout << " /\\ " << endl;
cout << " || " << endl;
cout << " || " << endl;
cout << " -- " << endl;
cout << " |++|" << endl;
cout << " ====" << endl;
printFirstTwoBuildingSection(2, 1);
printFirstTwoBuildingSection(4, 0);
}
cout << endl;
return 0;
}


Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









