how to find the index of an element in an array of arrays | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

how to find the index of an element in an array of arrays

how to find the index of an element in an array of arrays, for example: char [] [] array = {{'a', 'b', 'c'}, {'d', 'f', 'g'}}

4th Jan 2022, 10:38 AM
Роман Жигунов
Роман Жигунов - avatar
4 Antworten
+ 3
Use 2 nested loops (inner loop in outer loop,). Use one outer loop for traversing a row and other outer loop for traversing column For I to n { For J to m Array[I][J] , // I represents row while J represents columns.. } //For n*m array data
4th Jan 2022, 11:06 AM
Jayakrishna 🇮🇳
+ 1
using System; namespace Sololearn { class Program { static void Main(string[] args) { char[,]array ={{'a','b','c'},{'d','f','g'}}; for(int i=0; i<2;i++) { for(int j=0; j<3;j++) Console.Write(array[i,j]+" "); Console.Write("\n") ; } } } } //edit: corrected now to full code. cs syntax is different, just I noticed. Роман Жигунов..
5th Jan 2022, 10:53 AM
Jayakrishna 🇮🇳
0
Jayakrishna, please show an example
5th Jan 2022, 10:47 AM
Роман Жигунов
Роман Жигунов - avatar
0
Thank you
5th Jan 2022, 11:27 AM
Роман Жигунов
Роман Жигунов - avatar