方法A:C言語で表現は、絶対値関数来ます。
である場合の整数:ABS()
する#include <stdio.hに> する#include <math.h>の INT = 100 、B; B = ABS(A) のprintf(" %dの"、B)。
ある場合、浮動小数点数:double型 ファブ()
する#include <stdio.hに> する#include <math.h>の 浮遊 = 99.9 ; フロートBと、 B = ファブ(A) のprintf(" %のF "、B)。
方法2:自分自身の関数を記述し、言いました:
する#include <stdio.hの> INT ABS(int型T) { もし(T> 0 ) 戻りT; 他 リターン - T; } int型のmain() { int型、T = 0 ; scanf関数(" %のD "、&T)。 printf(" %dの" 、ABS(T)); 戻り 0 ; }