1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| public int[][]change_tableau(int[][] monTableau, int[] newPos, int[] oldPos)
{
int var;
int[][] temp = monTableau; // je recupere la reference :(
// Ici je switch les 2 elements que je veux modifier
var = temp[newPos[0]][newPos[1]];
temp[newPos[0]][newPos[1]] = temp[oldPos[0]][oldPos[1]];
temp[oldPos[0]][oldPos[1]] = var;
return temp; // temp == monTableau :(
}
public void fonctionAppel(//Parametre...)
{
int[][] tableau = new int [][]{0, 1...};
int[] newPos = new int[] { 0, 0 };
int[] oldPos = new int[] { 2, 2 };
int [][] temp;
temp = change_tableau(monTableau, newPos, oldPos);
// Affichage des resultats ici
} |