vendredi 29 octobre 2021

c++ Is there a way to rewrite this to be a more effective?

Just trying to write this in different ways

for (int i = 0; i < HOTPLATE_ROWS - 1; ++i) {
    for (int j = 0; j < HOTPLATE_COLUMNS - 1; ++j) {
        if((i >= 1 && i <= HOTPLATE_ROWS - 1) && (j > 0 && j < HOTPLATE_COLUMNS - 1)){
            finalTemperature[i][j] = (startTemperature[i - 1][j] + startTemperature[i][j 
            - 1]);
            finalTemperature[i][j] = (finalTemperature[i][j] + startTemperature[i][j + 1] 
            + startTemperature[i + 1][j]);
            finalArray[i][j] = finalTemperature[i][j] / TOUCHING_TEMPS;
            sumOfArray = finalArray[i][j];
     }
  }

}

Aucun commentaire:

Enregistrer un commentaire