标签:code abs main stdio.h name c语言 int printf pre
//求一个数的绝对值 #include <stdio.h> int absolute_value(int num) { if (num < 0) { num = ~(num - 1); } return num; } int main() { printf("%d\n", absolute_value(5)); printf("%d\n", absolute_value(-5)); printf("%d\n", absolute_value(0)); return 0; }
标签:code abs main stdio.h name c语言 int printf pre
原文地址:http://www.cnblogs.com/wgwyanfs/p/6782355.html