Created
June 20, 2018 14:37
-
-
Save beiweiqiang/922b5f57dafe134ad017ae886e9b78ff to your computer and use it in GitHub Desktop.
所有位为 0 时返回 1, 其它情况返回 0
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> | |
/* | |
* 所有位都为 0 时返回 1, 其他条件下产生 0 | |
* */ | |
int get_result(int x); | |
int main() { | |
printf("%d \n", get_result(1)); | |
printf("%d \n", get_result(-1)); | |
printf("%d \n", get_result(0)); | |
printf("%d \n", get_result(25645)); | |
printf("%d \n", get_result(0x73)); | |
return 0; | |
} | |
int get_result(int x) { | |
return !(x ^ 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment