![]() |
|
#1
|
|||
|
|||
Printing 2D matrix in coiled mannerPrint a 2D sqaure matrix using a recursive C function in a coiled manner. the function recieves only 2 arguments, the 2d matrix and the order of the matrix.
coiled manner implies the following path is to be taken: consider the 3X3 matrix 1 2 3 4 5 6 7 8 9 now the output is 5 2 1 4 7 8 9 6 3. starting from the central digit, one step up, then one left, then 2 down, then 2 right, then 3 up and so on. |
|||
|
#2
|
|||
|
|||
Re: Printing 2D matrix in coiled mannerIf you are asking how to make a 2D array, you simply use nested while loops. If not, I am sorry I cannot help you.
CPP / C++ / C Code:
Last edited by LuciWiz : 10-Oct-2008 at 14:17.
Reason: Please insert your C++ code between [cpp] & [/cpp] tags
|
|
#3
|
|||
|
|||
Re: Printing 2D matrix in coiled mannerA recursive solution may look something like this:
CPP / C++ / C Code:
__________________
My personal site: Utilities for text processing, debugging, testing and plotting |
|
#4
|
|||
|
|||
Re: Printing 2D matrix in coiled mannerThis logic is quite difficult to code this under recursion. You try first with normal loop first and once you get the patterns, reimplemented it with recursion.
I hope this help. |
|
#5
|
|||
|
|||
Re: Printing 2D matrix in coiled mannerQuote:
__________________
My personal site: Utilities for text processing, debugging, testing and plotting |
|
#6
|
|||
|
|||
Re: Printing 2D matrix in coiled mannerAlthough there are big difference between two of them but you can map the logic in your mind in case of iteration.
|
|
#7
|
|||
|
|||
Re: Printing 2D matrix in coiled mannerQuote:
CPP / C++ / C Code:
This is more evident when you start talking about recursive data structures such as trees. Using an iterative approach to implement find in an octtree will certainly not lead to any better understanding to the equivalent recursive one. __________________
My personal site: Utilities for text processing, debugging, testing and plotting |
Recent GIDBlog
Not selected for officer school by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multiply matrix (2 x 2)* with * as the power | resnealc | C++ Forum | 10 | 15-Nov-2007 08:11 |
| Printing to dot matrix printer | Lem0nHead | C Programming Language | 3 | 22-Mar-2007 11:09 |
| i need help in C++ PLZ | its_me | C++ Forum | 3 | 04-Dec-2006 21:51 |
| Printing an MxN matrix | kinkajou | C Programming Language | 4 | 06-Nov-2006 11:00 |
| Combining Vectors and References | Frankg | C++ Forum | 7 | 14-Jan-2006 06:17 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The