Skip to content

Instantly share code, notes, and snippets.

@Moverr
Created May 11, 2023 12:54
Show Gist options
  • Save Moverr/04bf7ae35c3fd5ce657aca2c5595d689 to your computer and use it in GitHub Desktop.
Save Moverr/04bf7ae35c3fd5ce657aca2c5595d689 to your computer and use it in GitHub Desktop.
Is Evenly Saced
#include <stdio.h>
int main(){
//int n[]={100,19,131,140};
//int n[]={200,1,151,160};
int n[]={200,10,151,160};
printf("Blessed \n ");
int value = evenSpaced(n,4);
printf("result : %d \n",value);
}
int evenSpaced(int arr[],int len){
if(len <2){
return 0;
}
int smallestnumber = arr[0];
int biggestnumber = arr[0];
for(int x =0; x<len; x++){
if(arr[x] < smallestnumber){
smallestnumber = arr[x];
}
if(arr[x] > biggestnumber){
biggestnumber = arr[x];
}
}
int result = biggestnumber - smallestnumber;
if(result %2 == 0){
return 1;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment