Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In the file Spirals / main . cpp , write a function Counting _ Spiral ( ) which generated a 2 D vector of
In the file "Spiralsmaincpp write a function CountingSpiral which generated a D vector of characters representing a spiral of numbers as show below.
The numbers will start at the center of the spiral and spiral outwards in the manner shown above.
The parameter length is the side length of the square and will always be an odd number, therefore there is always center.
The numbers will be modded by to ensure they are single digits.
Here is an example with length without the mod Not what your function should output
And here is the same example with the mod Desired Output
Here is what your vector indexes should look like for length
Algorithms:
The starting point of every spiral is the in the center
Always initialize vectors to the final size of the spiral
You should assume youre done when you hit the bounds of the vectors
Use a xy plane to visualize the algorithms first
Focus on creating some small spirals x & x first
#include iThere are two algorithms generate the spiral:
Imagine line segments spiraling out from the center. Each line segment bellow identified a different letter, and their direction rotates through the cardinal directions down, left right Every segments the length increases
right right
left left
down down
right
Define bounds within the plane create a small portion the spiral fill and then increase the bounds one each direction and repeat. When filling add numbers a direction until you hit a bound, then change direction.
Step 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