【c语言】将正数变成对应的负数,将负数变成对应的正数

<pre name="code" class="cpp">//  将正数变成对应的负数,将负数变成对应的正数

#include <stdio.h>

int turn(int a)
{
	a = ~a + 1;
	return a;
}

int main()
{
	printf("%d\n", turn(5));
	printf("%d\n", turn(0));
	printf("%d\n", turn(-1));
	return 0;
}

《【c语言】将正数变成对应的负数,将负数变成对应的正数》

    原文作者:zhaoyaqian552
    原文地址: https://blog.csdn.net/zhaoyaqian552/article/details/46696731
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞