Hi,
I have six arrays which is of float type. Any specific index in all these arrays represent set of values for me. Ex: if index is zero all the six arrays zeroth index represent a set of values, from which i need to find the max value. similarly for all other indexes.
array1 array2 array3 array4 array5 array6
0 0 0 0 0 0
1 1 1 1 1 1
-------------------------------------so on
i need to find out which is the max value of a specific index among all these arrays and should store it in another array or list
Loading
VulpesPosted Aug 25, 2011, 9:20 AM
VulpesPosted Aug 26, 2011, 10:31 AM
VulpesPosted Aug 25, 2011, 3:15 PM
Here's the C++/CLI code for that:
#include "stdafx.h"
using namespace System;
array
{
array
for(int i = 0; i < array2D->GetLength(0); i++)
{
float max = Single::MinValue;
for(int j = 0; j < array2D->GetLength(1); j++)
{
if (array2D[i, j] > max) max = array2D[i, j];
}
maxima[i] = max;
}
return maxima;
}
int main(array
{
array
{
{1, 2, 3, 4, 5, 6},
{7, 8, 9, 1, 2, 3},
{1, 2, 3, 10, 11, 12},
{-1, -2, -3, -4,-5, -6},
{-7, -8, -9, -3, -4, -5},
{4, 5, 6, -1, -2, -3}
};
array
// check it worked
Console::WriteLine("The maxima are \n");
for each(float f in maxima) Console::WriteLine(f);
Console::ReadKey();
return 0;
}
Sam HobbsPosted Aug 25, 2011, 2:33 PM
Also for C++ the Boost web site has an abundance of additional classes that can help. The Boost web site says that ten of the Boost libraries are in the new C++ standard. So it is likely that it is possible to use a library that is even more mature than the existing C++ Standard Library to write code now that will be compatible with the new standard.
VulpesPosted Aug 25, 2011, 1:39 PM
The only ones I'm reasonably fluent in nowadays are C#, C++ and VB though I have used several others in my time.
Sam,
Judging by the OP's previous thread, he's using C++/CLI.
Sam HobbsPosted Aug 25, 2011, 1:21 PM
Sam HobbsPosted Aug 25, 2011, 1:17 PM
Is this a class assignment? It sure sounds like one.
You might consider making a two-dimensional array and then you can use existing methods to access the set of values instead of writing a line of code for each one of the six values.
Suthish NairPosted Aug 25, 2011, 11:47 AM
Jaganathan BantheswaranPosted Aug 25, 2011, 9:11 AM
Store those specific index values in one array and compare that array value.