Write a C++ program incorporating recursion to solve the following problem. The program should compile and execute under the UNIX gcc or g++ environments. (show this please) In this program it needs to accept a sequence of k characters from the user and use the characters to produce a k concentric squares. Also assume that there is an index origin of 1, the outermost square is made up of the letter a[k], the square inside that is made from the letter a[k-1], the square inside that is made from the letter a[k-2], and so on, with the innermost square made from the letter a[1]. For example, if k=5, and the values of a are ("R","O","C","K","Y") then the executed program should display: Y Y Y Y Y Y Y Y Y Y K K K K K K K Y Y K C C C C C K Y Y K C O O O C K Y Y K C O R O C K Y Y K C O O O C K Y Y K C C C C C K Y Y K K K K K K K Y Y Y Y Y Y Y Y Y Y To make this program simpiler to do if you implement it in C++ and write a class; instances of this class can be passed by value. If a class is not used find an alternative way to pass an array by reference.
Write a C++
In this program it needs to accept a sequence of k characters from the user and use the characters to produce a k concentric squares. Also assume that there is an index origin of 1, the outermost square is made up of the letter a[k], the square inside that is made from the letter a[k-1], the square inside that is made from the letter a[k-2], and so on, with the innermost square made from the letter a[1]. For example, if k=5, and the values of a are
("R","O","C","K","Y") then the executed program should display:
Y Y Y Y Y Y Y Y Y
Y K K K K K K K Y
Y K C C C C C K Y
Y K C O O O C K Y
Y K C O R O C K Y
Y K C O O O C K Y
Y K C C C C C K Y
Y K K K K K K K Y
Y Y Y Y Y Y Y Y Y
To make this program simpiler to do if you implement it in C++ and write a class; instances of this class can be passed by value. If a class is not used find an alternative way to pass an array by reference.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images