【c语言】不用大与小与号,求两数最大值
// 不用大与小与号,求两数最大值 #include <stdio.h> int max(int a, int b) { int c = a - b; int d = 1 << 31; if ((c&d) == 0) { return a; } else { return b; } } int main() { printf("%d是大数\n", max(0, 2)); printf("%d是大数\n", max(3, 4)); printf("%d是大数\n", max(-1, 5)); return 0; }