// 求绝对值 #include <stdio.h> int fabs(int a) { if (a < 0) { a = ~a + 1; } return a; } int main() { printf("绝对值是:%d\n", fabs(5)); printf("绝对值是:%d\n", fabs(0)); printf("绝对值是:%d\n", fabs(-1)); return 0; }