Please help out. I want matrix B and G to outpit their values correctly. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Please help out. I want matrix B and G to outpit their values correctly.

https://www.sololearn.com/post/97256/?ref=app

9th May 2019, 8:24 AM
Source_code
Source_code - avatar
2 Answers
+ 2
Do NOT use 3 for-loops!!! Simply use a loop over x*y*z, then calculate your indices: bound = x*y*z for (index = 0, index < bound, index++) { idx = index % x idy = (index / x) % y idz = (index / (x*y)) % z matrix[idx, idy, idz] = .... } That's much more maintainable, readable and testable.
9th May 2019, 10:58 AM
Daniel Adam
Daniel Adam - avatar
0
Thanks
9th May 2019, 1:30 PM
Source_code
Source_code - avatar