jeck猫
整数用abs()函数例如:#include<stdio.h>#include<math.h>int main(){int a,b;scanf("%d",&a);b=abs(a);printf("%d",b);return 0;}输入-10,输出10。有小数的(即浮点型)用fabs()函数例如:#include<stdio.h>#include<math.h>int main(){double a,b;scanf("%lf",&a);b=fabs(a);printf("%lf",b);return 0;}输入-1.2,输出1.2