dimanche 12 mars 2023

Find max and min value in a 3D array using C++ [closed]

This is the question

I'm trying to print every value using for loop in this 3D array and save all values in an array(one-dimensional), then use the minmax_element() function to find max and min values. But now, I don't know how to save those values in an array(I am a beginner in c++ >-<).

for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
        for (int k = 0; k < 3; ++k)
            cout << "test[" << i << "][" << j << "][" << k << "] = " << test[i][j][k] << endl;

this can help me to get single value of whole 3D array and I want to store them in a one-dimentional array.

Aucun commentaire:

Enregistrer un commentaire