sqrt()函数,用于C ++中的复数
给定任务是找到sqrt()复数的函数的作用。基本上,sqrt()是复杂头文件中存在的函数。此函数用于计算复数的平方根。
语法
template<class t> complex<t> Sqrt(const complex<t>& x);
参数
x-此参数x代表复数。
返回值
此函数返回复数的平方根。
输入 -Sqrt(3,8i)
输出-(2.4024,1.6649)
输入Sqrt(7,1i)
输出-(2.6524,0.1885)
示例
#include<iostream.h>
#include<complex.h>
Using namespace std;
int main( ){
/ / Defining of complex Number
Complex<double> x(4,9);
Cout<< “ The square root of “ << x << “ = “ << sqrt(x) << endl;
Return 0;
}输出结果
如果我们运行上面的代码,它将生成以下输出
The square root of (4,9) = (2.631,1.710)
示例
#include<iostream.h>
#include<complex.h>
Using namespace std;
int main( ){
/ / defining the complex Number
Complex<double> x(2, 6);
Cout<< “ The square root of “ << x << “ = “ << sqrt(x) << endl;
return 0;
}输出结果
如果我们运行上面的代码,它将生成以下输出
The square root of (2,6) = (2.0401,1.4704)
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短