[ create a new paste ] login | about

Link: http://codepad.org/MRh6ckbL    [ raw code | output | fork ]

C++, pasted on Mar 13:
#include<cstdlib>
#include<cstdio>
#include<string>

#define N 5

void neighbors(int *arr, int dim, int *equal){

int *t=arr;
*equal=0;
int i;

for(i=1;t[i]<5;i++){
    if(((t[i-1]+t[i+1])/2)==t[i])
        (*equal)++;
    else
        continue;
}
printf("Elements -> %d", *equal);
}

int main(){


int array[N]={1,2,3,9,10};
int aux;

neighbors(array,N,&aux);
}


Output:
1
Elements -> 1


Create a new paste based on this one


Comments: