iGuest 3 Report post Posted May 29, 2011 1.program to convert a two dimensional array to one dimensional array.2.program to convert one dimensional array to two dimensional array. Share this post Link to post Share on other sites
Quatrux 4 Report post Posted June 3, 2011 I think here is a good link which might help you to write such programs in C++https://answers.yahoo.com/question/index?qid=20081012031554AApY0dO:) Share this post Link to post Share on other sites
multfilm 0 Report post Posted May 26, 2012 So I guess if you are allowed just to copy from the internet, the link above is exactly the program you would need. But probably you would wish to be able to understand yourself how it works. So basically you have the two arrays, and then you assign an invertible function from the double array to the single array. To go one way, you apply this function when copying the array; to go the other way, you apply its inverse. Share this post Link to post Share on other sites
k_nitin_r 8 Report post Posted August 12, 2012 A two dimensional array has a pair of indexes that you can work with so if you have a 3x3 array, you have 9 elements. If you want to turn the 2-dimensional array into a 1-dimensional array, you can either go with the approach in the link posted, or you can treat the 2-dimensional array as a 1-dimensional array assuming that the elements for the 2-dimensional array are stored sequentially.To do this, get a pointer to the first element of the 2-dimensional array. You can then treat the pointer as a 1-dimensional array and copy elements from it to the actual 1-dimensional array. It's one of the advantages of C wherein you can treat one piece of structured data as a totally different structure through casting and pointers. Share this post Link to post Share on other sites