tan()函数,用于C ++中的复数
在本文中,我们将讨论tan()C++STL中复数的工作原理,语法和函数示例。
tan()用于复数是<complex>头文件下的函数。此函数用于查找与其关联的复数的切线。此功能是tan()<cmath>头文件下的simple的复杂版本。
什么是复数?
复数是由实数和虚数组成的数字。
它们写为:a+bi
其中a和b是实数,而i是虚数。
语法
template<class T> complex<T> tan (const complex<T>& num);
参数
该函数仅接受一个参数num,它是一个复杂值。
返回值
它返回num的正切值。
示例
Input: complex <double> num(0.0, 1.0); tan(num); Output: (0, 1.55741)
示例
#include <iostream>
#include <complex>
using namespace std;
int main () {
complex<double> tan_num(9.1, 2.6);
cout<<"tan of "<<tan_num<<" is "<<tan(tan_num);
return 0;
}输出结果
如果我们运行上面的代码,它将生成以下输出-
tan of (9.1, 2.6) is (-0.00661488, 0.99123)
示例
#include <iostream>
#include <complex>
using namespace std;
int main () {
complex<double> tan_num(1.0, 0.0);
cout<<"tan of "<<tan_num<<" is "<<tan(tan_num);
return 0;
}输出结果
如果我们运行上面的代码,它将生成以下输出-
tan of (1, 0) is (1.55741, 0)
热门推荐
10 高一祝福语简短 励志
11 立秋节气简短祝福语
12 简短公司周年祝福语大全
13 中考感言简短祝福语大全
14 体育老师简短祝福语
15 干杯生日祝福语简短独特
16 特别简短的祝福语老师
17 朋友坐车走了祝福语简短
18 给英雄的祝福语简短