Output for each value i, j

in the code below that belongs to the floyd algorithm, how can I print the output for each i, j value? for example, the shortest distance [0,0] = 2 and the shortest [0,1] = 4, etc. now it prints the shortest distance from i to j: 3 (for example)

private void button10_Click(object sender, EventArgs e) { string ab = textBox11.Text; int matrixDimention = Convert.ToInt32(ab); int[,] intValues = new int[matrixDimention, matrixDimention]; string[] splitValues = textBox9.Text.Split(','); for (int i = 0; i < splitValues.Length; i++) intValues[i / (matrixDimention), i % (matrixDimention)] = Convert.ToInt32(splitValues[i]); string displayString = ""; for (int inner = 0; inner < intValues.GetLength(0); inner++) { for (int outer = 0; outer < intValues.GetLength(0); outer++) displayString += String.Format("{0}\t", intValues[inner, outer]); displayString += Environment.NewLine; } int n=matrixDimension MessageBox.Show("matrix"+strn+ "in" + strn + "is\n\n\n" +displayString); ////before this line i wrote the codes to get the numbers that user enter in textbox and put it in an 2d array for (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { if (intValues[i, j] > intValues[i, k] + intValues[k, j]) { intValues[i, j] = intValues[i, k] + intValues[k, j]; string str_intvalues = intValues[i, j].ToString(); MessageBox.Show("Shortest Path from i to j is: " + str_intvalues); } else { string str_intvalues = intValues[i, j].ToString(); MessageBox.Show("Shortest Path from i to j is: " + str_intvalues); } } } 
+4
source share
1 answer

i edited both of MessageBox.show () in this form, and he fixed:

 MessageBox.Show("Shortest distance from" + i + " to " + j + " isnnt: " + str_intvalues); 
+2
source

Source: https://habr.com/ru/post/1333299/


All Articles