#ifdef _WIN32 #include #else #include #endif #include #include using namespace std; class GenrateShape { public: void SqaureShape(int length) { for (int row = 1; row <= length; row++) { sleep (1); for (int col = 1; col <= length; col++) { cout << "p"<< " "; } cout << endl; } } void TriangleShape(int length) { for (int i = 1; i <= length; i++) { sleep(1); for (int j = length - i; j > 0; j--) cout << " "; for (int b = 1; b <= i; b++) cout << "p" << " "; cout << endl; } } void pentagonShape(int length) { TriangleShape(length); SqaureShape(length); } }; int main() { int length = 13; GenrateShape shape; shape.pentagonShape(length); return 0; } DESIGN (ALGORITHM): On a piece of paper (or word processor), write down the algorithm, or sequence of steps, that you will use to solve the problem. You may think of this as a “recipe” for someone else to follow. Continue to refine your “recipe” until it is clear and deterministically solves the problem. Be sure to include the steps for prompting for input, performing calculations, and displaying output. You should attempt to solve the problem by hand first (using a calculator as needed) to work out what the answer should be for a few sets of inputs. Type these steps and calculations into a document (i.e., Word, text, or PDF) that will be submitted along with your source code. Note that if you do any work by hand, images (such as pictures) may be used, but they must be clear and easily readable. This document shall contain both the algorithm and any supporting hand-calculations you used in verifying your results.
I have to write an
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
#include <iostream>
#include <cstdlib>
using namespace std;
class GenrateShape {
public:
void SqaureShape(int length) {
for (int row = 1; row <= length; row++)
{
sleep (1);
for (int col = 1; col <= length; col++)
{
cout << "p"<< " ";
}
cout << endl;
}
}
void TriangleShape(int length) {
for (int i = 1; i <= length; i++)
{
sleep(1);
for (int j = length - i; j > 0; j--)
cout << " ";
for (int b = 1; b <= i; b++)
cout << "p" << " ";
cout << endl;
}
}
void pentagonShape(int length) {
TriangleShape(length);
SqaureShape(length);
}
};
int main()
{
int length = 13;
GenrateShape shape;
shape.pentagonShape(length);
return 0;
}
DESIGN (ALGORITHM):
On a piece of paper (or word processor), write down the algorithm, or sequence of steps, that you will
use to solve the problem. You may think of this as a “recipe” for someone else to follow. Continue to
refine your “recipe” until it is clear and deterministically solves the problem. Be sure to include the steps
for prompting for input, performing calculations, and displaying output.
You should attempt to solve the problem by hand first (using a calculator as needed) to work out what
the answer should be for a few sets of inputs.
Type these steps and calculations into a document (i.e., Word, text, or PDF) that will be submitted along
with your source code. Note that if you do any work by hand, images (such as pictures) may be used, but
they must be clear and easily readable. This document shall contain both the algorithm and any supporting
hand-calculations you used in verifying your results.
Step by step
Solved in 3 steps