Transposée d'une matrice [Java]
Fermé
Kbibi
-
16 déc. 2011 à 10:40
Char Snipeur Messages postés 9696 Date d'inscription vendredi 23 avril 2004 Statut Contributeur Dernière intervention 3 octobre 2023 - 3 janv. 2012 à 11:43
Char Snipeur Messages postés 9696 Date d'inscription vendredi 23 avril 2004 Statut Contributeur Dernière intervention 3 octobre 2023 - 3 janv. 2012 à 11:43
1 réponse
assasin altair
Messages postés
4
Date d'inscription
lundi 2 janvier 2012
Statut
Membre
Dernière intervention
2 janvier 2012
3
2 janv. 2012 à 20:52
2 janv. 2012 à 20:52
public static Matrice matrice_transposée (Matrice M) {
Matrice tmp=new Matrice();
tmp.ligne = M.colonne;
tmp.colonne = M.ligne;
tmp.mat = new int[tmp.ligne][tmp.colonne];
for (int i=0; i<M.ligne; i++)
for (int j=0; j<M.colonne; j++)
tmp.Mat[i][j] = M.Mat[j][i];
return tmp;
}
Matrice tmp=new Matrice();
tmp.ligne = M.colonne;
tmp.colonne = M.ligne;
tmp.mat = new int[tmp.ligne][tmp.colonne];
for (int i=0; i<M.ligne; i++)
for (int j=0; j<M.colonne; j++)
tmp.Mat[i][j] = M.Mat[j][i];
return tmp;
}
3 janv. 2012 à 11:43
D'ailleurs, j'aurai plutôt écris: