English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How do i change from a 2d vector array into a 3d form? I actually have some data in the following 2d format which need some transformation...

Example:
a1 b1 c11 c12 c13 c14
a1 b2 c21 c22 c23 c24
a1 b3 c31 c32 c33 c34
a2 b1 d11 d12 d13 d14
a2 b2 d21 d22 d23 d24
a2 b3 d31 d32 d33 d34

In the 3d form (array[x][y][z]) , i will first read a1 into x, b1 into y and each row's Cs into z, after which repeat till b2 and b3 are read in, then move on to read a2 into x, b1 into y and each row's Ds into z. Again, reading till the Cs of b2 and b3 are read in.

Sorry for sounding a bit confusing but I'm already trying my best to explain. Any valuable input will be appreciated. Thanks!!

2007-01-13 16:52:07 · 2 answers · asked by blurry 1 in Computers & Internet Programming & Design

2 answers

From your description, you are trying to fit c11 AND c12 And c13 AND c14 into ONE variable - z in the array.

It's Not Going To Work!

Either attenuate your data, or use an array with 5 variables (dimensions).

2007-01-13 17:36:04 · answer #1 · answered by Alan 6 · 0 0

i'm extra of a c guy or woman than c++, yet in c, you are able to use malloc for that (will paintings high-quality in c++ to boot, yet continues to be an array, and not a c++ vector). int *arraysize = (int*)malloc(sizeof(int) * measurements); What which will do is create a pointer, then dynamically allocate measurements * the dimensions of an int to it, for this reason making it an array of mesurements length. I purely examined it then and it labored, yet whilst it complains, #comprise to boot. additionally, i'm assuming "cin >> measurements[ i ];" could desire to be "cin >> arraysize[ i ];" suitable? wish that facilitates :)

2016-12-13 05:57:13 · answer #2 · answered by ? 4 · 0 0

fedest.com, questions and answers