//Bonsoir, ce programme -sans erreur- ne retourne pas de résultat je ne sais //pourquoi ?
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
class ff{ 
	  int[][] c = { 
	    {0, 3, 8, M, -4}, 
	    {M, 0, M, 1, 7}, 
	    {M, 4, 0, M, M}, 
	    {2, M, -5, 0, M}, 
	    {M, M, M, 6, 0} 
	  }; 
	  static final int M = Integer.MAX_VALUE; 
		public int[][] getc() { 
			return c; 
		} 
	  static int[][] floydm(int[][] c) { 
		    int n = c.length; 
		    int[][] d = new int[n][n]; 
		    for (int i=0; i<n; i++) { 
		      for (int j=0; j<n; j++) { 
		        d[i][j] = c[i][j]; 
		        } 
		    } 
		    for (int k=0; k<n; k++) { 
		      for (int i=0; i<n; i++) { 
		        for (int j=0; j<n; j++) { 
		          int dik = d[i][k], dkj = d[k][j]; 
		          if (dik == M || dkj == M) continue; 
		          int u = dik + dkj; 
		          if (u < d[i][j]) { 
		            d[i][j] = u; 
		          } 
		        } 
		      } 
		    } 
		    return d; 
		  }} 
public class floyd {  
	public static void main(String[] args) {  
		ff matrice ; 
	matrice =new ff(); 
		ff.floydm(matrice.getc()); 
	} 
	}