C ++中的fdim()
在这里,我们将看到fdim()C++中的功能是什么。该fdim()函数用于返回两个给定参数之间的正差。如果两个参数分别是a和b,并且如果a>b,则它将返回a–b。否则返回0。
示例
#include <cmath>
#include <iostream>
using namespace std;
main() {
cout << "fdim of (5.0, 2.0) is " << fdim(5.0, 2.0) << endl; //positive difference
cout << "fdim of (2.0, 5.0) is " << fdim(2.0, 5.0) << endl; //this will return 0
cout << "fdim of (-5.0, -2.0) is " << fdim(-5.0, -2.0) << endl; //this will return 0
cout << "fdim of (-2.0, -5.0) is " << fdim(-2.0, -5.0) << endl; //positive difference
}输出结果
fdim of (5.0, 2.0) is 3 fdim of (2.0, 5.0) is 0 fdim of (-5.0, -2.0) is 0 fdim of (-2.0, -5.0) is 3
热门推荐
10 男孩上学祝福语简短英语
11 送去考试祝福语简短英文
12 给干爸过年祝福语简短
13 道士结婚文案祝福语简短
14 幼教专干调动祝福语简短
15 祝福语赠言给老师简短
16 城堡文案简短婚礼祝福语
17 妹妹住院祝福语简短英文
18 财神祝福语简短情话文案