Question
/******************************************************************************** * vDIAMONDS * author(s): * adapted from: array version from class * other citations: * * goal: Output a diamond of user determined size
/******************************************************************************** * vDIAMONDS * author(s): * adapted from: array version from class * other citations: * * goal: Output a diamond of user determined size must use a 2D vector. * example: for input of 5 * for an input of 6 /\ * *** //\\ * ***** ///\\\ * *** \\\/// * * \\// * \/ * overview:(1) ... ********************************************************************************/
#include
int main() { const int MAX_WIDTH = 80; const char BACKGRND_CHAR = '.'; const char ODD_CHAR = "*"; return 0; } // end main()
Taking size input from the user, draw a diamond with square dimensions (i.e. width = height). Part of the requirement is to populate a two-dimensional vector, and then output the vector to the screen. If the given width is odd, the diamond should be drawn with stars (the " character) and if the diamond is even, it should be drawn with forward and backward slashes (the " \ " and "/" characters). The background should be periods (rather than spaces) so they will show up clearly. So for example, entering 11 would give the left diamond below, and the right-hand diamond is from the input 12. Note that the template has constants for two of the characters - you should add constants for the other two. Additionally there is a constant for the maximum width. If the user enters bad data the program should output: The size must be between 1 and 80 . where 80 is the value of the constant MAX_WIDTH. It might be helpful to know that pre-filling a vector, such as vectorStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started