abs()函数可用于c + +中的复数?
C++中的abs函数用于查找复数的绝对值。复数的绝对值(也称为模数)是该数与复数平面中的原点的距离。这可以使用公式找到-
对于复数a+bi:
mod|a+bi| = √(a2+b2)
该abs()函数在C++中返回上述计算的结果。它在需要包含的复杂库中定义。
abs()在C++中显示对复数使用功能的程序
#include <iostream>
#include <complex>
using namespace std;
int main () {
float a= 13.0 , b = 5.0;
complex<double> complexnumber (a, b);
cout << "The absolute value of " << a<<"+"<<b<<"i" << " is: ";
cout << abs(complexnumber) << endl;
return 0;
}输出结果
The absolute value of 13+5i is: 13.9284
热门推荐
10 南宁招生老师祝福语简短
11 公司年会祝福语简短最好
12 关于出国留学祝福语简短
13 八一祝福语简短文字
14 爱人出国祝福语简短英文
15 小孩生日祝福语简短励志
16 红包祝福语简短10字
17 给升迁同事祝福语简短
18 换工作简短特别祝福语