Skip to content

Instantly share code, notes, and snippets.

@7PintsOfCherryGarcia
Last active June 18, 2019 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7PintsOfCherryGarcia/434801eb9a99652ae4384afd13f02682 to your computer and use it in GitHub Desktop.
Save 7PintsOfCherryGarcia/434801eb9a99652ae4384afd13f02682 to your computer and use it in GitHub Desktop.
Add elements in an array if they are greater or equal to n
#include <stdio.h>
int main() {
int array[20] = {12,99,14,2,35,67,21,1,12,89,74,32,45,6,78,41,22,54,37,84};
int n = 50;
int sum = 0;
int tmp;
for (int i = 0; i < 20; i++) {
t = (array[i] - n) >> 31;
sum += ~t & array[i];
}
return 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment