Bonsoir,
J'ai un problème avec un code d'addition et de multiplication de matrices :
je ne comprends pas pourquoi il ne fonctionne pas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
import javax.swing.*;
import java.util.*;
public class Mat{
public static void main(String args[]){ 
int matriceentier1[][]={{4,0,1},{1,2,5},{2,5,3}}; 
System.out.println(" la matrice x"); 
for(int i=0; i< 3;i++) 
{ 
for(int j=0; j<3;j++) 
{ 
System.out.print(matriceentier1[i][j]+" " ); 
} 
System.out.println(" ");
}
int matriceentier2[][]={{4,0,1},{1,2,5},{2,5,3}}; 
System.out.println(" la matrice y"); 
for(int i=0; i< 3;i++) 
{ 
for(int j=0; j<3;j++) 
{ 
System.out.print(matriceentier2[i][j]+" " ); 
} 
System.out.println(" "); 
 
} 
System.out.println(" la matrice x+y"); 
for(int i=0; i< 3;i++) {
 
for(int j=0; j<3;j++) {
 System.out.print(" "+(matriceentier1[i][j]+matriceentier2[i][j]));
//int som [i][j]=matriceentier1[i][j] + matriceentier2[i][j];
}
System.out.println(" "); 
}
System.out.println(" la matrice x*y"); 
 
 
for(int i=0; i< 3;i++) {
 
for(int j=0; j<3;j++) {
int produit[i][j]=produit[i][j]+(matriceentier1[i][j]*matriceentier2[i][j]);
 
//System.out.print(" "+produit[i][j]+(matriceentier1[i][j]*matriceentier2[i][j]));
}
} 
}
}
Ce qui est en commentaire ne fonctionne pas non plus. Il y a une erreur pour chaque caractère.
Merci d'avance pour vos réponses.