You could have two loops, the outer one to hold the value of the current element value then the inner one steps through the entire array and counts the adjacent occurences of the current element,
The below definitely will not work and do the whole thing for you and there are gaps in the logic and things you need to figure out in order to complete the task, and the idea shown definitely depends on your data only being a simple data set say, 0 - 20, otherwise i would do things a bit differently. I am not about to do homework, but it should give you some ideas on one approach to start you off
Code:
for(i = 0; i < maxVal; i++)
{
currentVal = array[i];
temp = array[i];
for j = 0; j < maxVal; j++)
{
if(array[j] == array[i])
{
adjCount++;
}
else
{
lastHigh[temp] = adjCount;
adjCount = 0;
}
}
}