<pre name="code" class="cpp">// 将正数变成相应的负数,将负数变成相应的正数 #include <stdio.h> int turn(int a) { a = ~a + 1; return a; } int main() { printf("%d ", turn(5)); printf("%d ", turn(0)); printf("%d ", turn(-1)); return 0; }
<pre name="code" class="cpp">// 将正数变成相应的负数,将负数变成相应的正数 #include <stdio.h> int turn(int a) { a = ~a + 1; return a; } int main() { printf("%d ", turn(5)); printf("%d ", turn(0)); printf("%d ", turn(-1)); return 0; }