Deutsch English Français Italiano |
<QqGdnSnMyKKJDtX_nZ2dnUU7_8zNnZ2d@giganews.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 02 Apr 2022 13:16:52 -0500 Newsgroups: fr.comp.lang.java Subject: probl�me d'affichage avec des calculs de matrice X-poster: PEAR::Net_NNTP v1.5.0 (stable) From: freddye <nospam_ninonlois33@gmail.com.invalid> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Organization: !No_Organization! Message-ID: <QqGdnSnMyKKJDtX_nZ2dnUU7_8zNnZ2d@giganews.com> Date: Sat, 02 Apr 2022 13:16:52 -0500 Lines: 101 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-1zgNhXfkiPJk9Jo4ej/iSie4NX1tto9VnXqyh7ncNSBwRfqfyDndZOm3AU4PJ9FoQy+eUV6sCvJqswb!z4DueRu0kjdIgFhilnJduARagFuWBvMaRmc7bcvX7FWnXTErpcdr9VvInp5nhXDD9gTTdElB/Pq7 X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Bytes: 3122 Bonjour, Vous pourrez retrouver ci-dessous une classe Matrice qui me permet de calculer la transpos� d'une matrice. Mais la sortie n'est pas celle attendu... Voici mon code : public class Matrice { private int[][] coeff = null; public Matrice(int i, int j) { this.setLength(i,j); } public Matrice() { this(0,0); } public Matrice(int[][] mat) { this.coeff = mat; } // définit une matrice de type int[][] public void setMatrice(int[][] mat) { this.coeff = mat; } // définit une valeur � la position i et j // i - ligne // j - col public void setValue(int i, int j, int value) { this.coeff[i][j] = value; } // on définit la taille de la mtrice public void setLength(int i, int j) { this.coeff = new int[i][j]; } public int[][] getMatrice() { return this.coeff; } // retourne le nombre de ligne public int getRows() { return this.coeff.length; } // retourne le nombre de colonne public int getColumns() { return this.coeff[0].length; } // retourne la valeur � la position i et j public int getValue(int i, int j) { return this.coeff[i][j]; } // transpose la matrice public Matrice getMatriceTranspose() { Matrice a = new Matrice(this.getColumns(), this.getRows()); int tmp = 0; for (int i=0; i<a.getRows(); i++) for (int j=0; j<a.getColumns(); j++) { tmp = this.getValue(j,i); a.setValue(i,j,tmp); } return a; } public static void main(String[] args) { Matrice a = new Matrice(); a.setMatrice(new int[][] {{1,2},{3,4}}); System.out.println("Matrice inverse : n" + a.getMatriceTranspose()); } } Et j'obtiens la sortie suivante : Matrice inverse : calculMat.Matrice@2aae9190 J'esp�re que quelqu'un pourra m'�clairer... Merci d'avance.