Last active
June 18, 2019 14:19
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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