Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7.26 Draw a Diamond, vector edition Taking size input from the user, draw a diamond with square dimensions (i.e. width = height). Part of the

image text in transcribedimage text in transcribed

7.26 Draw a Diamond, vector edition 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 "I" 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 vector>diamond{{1,b,c},{2,b,c},{3,b,c},; will only work if the compiler supports C++11 or higher. And though the 11 refers to 2011 , a surprising number of compilers are still not caught up. Without a C++11 compiler, it's probably best to declare the 2D vector, giving only the row size. Then step through the rows and create the columns. Initialization can happen at the same time. Another requirements is that, as when we finished the array version, two functions must be created. One will print a row and the other will fill a row. But only one row at a time may be passed up, and it should be a parameter not a return value. So, in the same way we approached the array, a 2D vector will be created, populated by calling functions that take a 1D vector. main.cpp Load default template

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

=+ c. a company president deciding whether to open a new factory

Answered: 1 week ago