English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

تعليميات C++ الأساسية

C++ 流程控制

وظيفة C++

C++ 数组 & 字符串

C++ 数据结构

C++ 类 & 对象

مؤشرات C++

الوراثة الخاصة بـ C++

دليل C++ STL

C++ 参考手册

C++ atan() 函数使用方法及示例

وظائف المكتبة الخاصة بـ C++ <cmath>

C ++中的atan()函数以弧度形式返回数字(参数)的反正切值。

此函数在<cmath>头文件中定义。

[数学] tan-1x = atan(x) [C++];

atan()原型[从C ++ 11标准开始]

double atan(double x);
float atan(float x);
long double atan(long double x);
double atan(T x); //为整型

atan()参数

atan()函数采用一个强制性参数(可以为正,负或零)

atan()返回值

atan()函数返回[-π/ 2،π/ 2]范围内的值。

示例1:atan()如何工作?

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  double x = 57.74, result;
  result = atan(x);
  
  cout << "atan(x) = " << result << " radians" << endl;
  
  //إخراج درجات
  cout << "atan(x) = " << result*180/3.1415 << " degrees" << endl;
  
  return 0;
}

عند تشغيل هذا البرنامج، الناتج هو:

atan(x) = 1.55348 رياضيات
atan(x) = 89.0104 درجات

示例2:具有整数类型的atan()函数

#include <iostream>
#include <cmath>
#define PI 3.141592654
using namespace std;
int main()
{
  int x = 14;
  double result;
  
  result = atan(x);
  
  cout << "atan(x) = " << result << " radians" << endl;
  //إخراج درجات
  cout << "atan(x) = " << result*180/3.1415 << " degrees" << endl;
  
  return 0;
}

عند تشغيل هذا البرنامج، الناتج هو:

atan(x) = 1.49949 راديان
atan(x) = 85.9169 درجات

  وظائف المكتبة الخاصة بـ C++ <cmath>