0

Can someone help me on creating an multi array

1 2 3. 9 8 7 4 5 6 to 6 5 4 7 8 9 3 2 1

14th Nov 2016, 4:18 PM
Pa Modou Faal
8 Respuestas
0
// Two-dimensional array. int[,] array2D = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; // The same array with dimensions specified. int[,] array2Da = new int[4, 2] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; //A similar array with string elements string[,] array2Db = new string[3, 2] { { "one", "two" }, { "three", "four" }, { "five", "six" } }; // Three-dimensional array. int[, ,] array3D = new int[,,] { { { 1, 2, 3 }, { 4, 5, 6 } }, { { 7, 8, 9 }, { 10, 11, 12 } } }; // The same array with dimensions specified. int[, ,] array3Da = new int[2, 2, 3] { { { 1, 2, 3 }, { 4, 5, 6 } }, { { 7, 8, 9 }, { 10, 11, 12 } } }; // Accessing array elements System.Console.WriteLine(array2D[0, 0]); System.Console.WriteLine(array2D[0, 1]); System.Console.WriteLine(array2D[1, 0]); System.Console.WriteLine(array2D[1, 1]); System.Console.WriteLine(array2D[3, 0]); System.Console.WriteLine(array2Db[1, 0]); System.Console.WriteLine(array3Da[1, 0, 1]); System.Console.WriteLine(array3D[1, 1, 2]); // Getting the total count of elements or the length of a given dimension. var allLength = array3D.Length; var total = 1; for (int i = 0; i < array3D.Rank; i++) { total *= array3D.GetLength(i); } System.Console.WriteLine("{0} equals {1}", allLength, total); // Output: // 1 // 2 // 3 // 4 // 7 // three // 8 // 12 // 12 equals 12
14th Nov 2016, 10:12 PM
Abdelaziz Abubaker
Abdelaziz Abubaker - avatar
0
Sorry I write the code in much detail as I could have
14th Nov 2016, 10:13 PM
Abdelaziz Abubaker
Abdelaziz Abubaker - avatar
0
can I get it on C++
15th Nov 2016, 2:54 AM
Pa Modou Faal
0
devc++
15th Nov 2016, 2:54 AM
Pa Modou Faal
0
yeah sure
15th Nov 2016, 3:15 AM
Abdelaziz Abubaker
Abdelaziz Abubaker - avatar
0
thanks bro
15th Nov 2016, 3:22 AM
Pa Modou Faal
0
int x[2][3] = { {2, 3, 4}, // 1st row {8, 9, 10} // 2nd row };
15th Nov 2016, 4:16 AM
Abdelaziz Abubaker
Abdelaziz Abubaker - avatar