mercredi 22 avril 2020

trying to output the element of an array in c++

I am trying to search which elements in this c++ array contain the highest value and then output the key of that element but it keeps outputting a list of numbers like 9044007. What I want to know is how do I output the first number only because I'm guessing it is outputting all the keys of the elements with the same value.

double max = 0;
for (int i = 1; i <= 9; i++) {
    if (responselayer[i] > max) {
        max = responselayer[i];
    }
}
for (int i = 1; i < 10; i++) {
    if (responselayer[i] == max) {
        return i;
        break;
    }
}

Aucun commentaire:

Enregistrer un commentaire