char[][] M = new char[][];
init(M);
count = 0;
for each row:
for each element of the row:
if M[row][column] == specific_char:
count = count + 1;
return count;
Count numbers of a specific character in a DFS algorithm?
-
09-07-2023 - |
سؤال
How can i find a algorithm that count numbers of a specific character in a matrix? Im thinking a DFS?
the matrix could look like this:
xxxxx
x nxx
xx xx
xnxxx
xxxxx
And i want to count the numbers of n in the matrix?
Im not good at algorithms so please be gentle with me :)
المحلول
نصائح أخرى
matrix[i][j];//matrix 10x10
j = 0;
i = 0;
for(j = 0 ; j < 9; j++){
for(i = 0; i < 9 ; i++;){
if(matrix[j][i] == character){...}
}
}
لا تنتمي إلى StackOverflow