using System;
///An integer array is said to be evenSpaced, if the difference between the largest value and the smallest value is an evennumber. Write a function isEvenSpaced(int[] a) that will return 1 if it is evenSpaced and 0 otherwise. If array has less than two elements, function will return 0. If you are programming in C or C++, the function signature is:
///int isEvenSpaced (int a[ ], int len) where len is the number of elements in the array.
///Examples
///Array Largest value Smallest value Difference Return value
///{100, 19, 131, 140} 140 19 140 -19 = 121 0
///{200, 1, 151, 160} 200 1 200 -1 = 199 0
///{200, 10, 151, 160} 200 10 200 -10 = 190 1
///{100, 19, -131, -140} 100 -140 100 - (-140 ) = 240 1
///{80, -56, 11, -81} 80 -81 -80 - 80 = -161 0
public class Program
{
public static void Main()
int [] a = {200, 10, 151, 160}; //{100, 19, 131, 140}
Console.WriteLine(isEvenSpaced(a));
Console.ReadLine();
}
private static int isEvenSpaced(int [] a)
if(a.Length <= 1) return 0;
int max = a[0];
int min = a[0];
foreach(int n in a)
max = (max<n)?n:max;
min = (min>n)?n:min;
if((max-min) >= 0 && (max-min) % 2 == 0) return 1;
return 0;