Well the header of this question isn't really clear but I can't [at this point of time] think of a better explanation than the real problem itself which is: I have a method of a class let it be donated as max_val[the name of the method not the class]. max_val run on the class does some calculates and return an answer between 1 to 100 (for my question it is not really important how and what this method does let's say she return this value randomly ). max_val returns an int type. In the main program I have
void main()
{
bla bla some class defines;
....
int max =0;
for (int z = 1; z < 11; z++)
{
for (int x = 1; x < 11; x++)
{
for (int c = 1; c < 11; c++)
{
for (int v = 1; v < 11; v++)
{
int check_m = max_val(z,x,c,v);
......
}
}
}
}
}
now instead of the 2nd .... what I want to do is to check if check_m > max then replace max=check, but but I want at the end of all the fores (fores or fors?) to print to screen the max val and his matching configurations . notice that there might be more than one configuration for same global maximum max. In case it isn't clear in configuration I mean what were the (z,x,c,v) that gave the maximum max.
I only thought about printing each time change occurs "new max and new configuration ..." , or when check+m == max " added configuration ..." but OFC this is the easy solution .
I hope I made it clear enough .
Aucun commentaire:
Enregistrer un commentaire