In a method i am calculating the longest row of elements. The 1-dim array is filled up with random values (0 or 1).
The method looks up the longest row (being 0 or 1, whatever is the longest).
Meaning in for example:
1110100 --> the longest row would be 3 (3 * 1)
0110000 --> the longest row would be 4 (4 * 0)
My problem is i am trying to perform some type of linear search to show the position of the row in the array (seperate method to keep it nice and tidy).
The first example has the longest row of 3 elements (3 times 1).
For 1110100 the position in the array would be 0 - 2 (index)
For 0110000 the position in the array would be 3 - 6 (index)
I have been trying with foreaches, for loops etc..but i cannot seem to get the proper indexes of both.
Cannot seem to display both positions properly. Been trying for hours.
For the first example the correct output wouldbe: The largest row of same elements of the array consists of 3 elements on the position 0 -> 2.
The longest row of elements gets of same elements get calculated as the following:
public int BerekenDeelrij (int  table) ( int count = 0; int LastValue = 0, int largest = 0; for (int i = 0; i <tabel.Length; i++) ( if (LastValue == table[i]) counter++; else ( = Math.Max largest (largest, counter); LastValue = table[i]; counter = 1; ) ) Math.Max return (largest, counter); )
Edited by Nerathas: n/a