亚洲区国产区激情区无码区,国产成人mv视频在线观看,国产A毛片AAAAAA,亚洲精品国产首次亮相在线

C++ 基礎(chǔ)教程

C++ 流程控制

C++ 函數(shù)

C++ 數(shù)組 & 字符串

C++ 數(shù)據(jù)結(jié)構(gòu)

C++ 類 & 對(duì)象

C++ 指針

C++ 繼承

C++ STL 教程

C++ 參考手冊(cè)

C++ acos() 函數(shù)使用方法及示例

C++ 庫(kù)函數(shù) <cmath>

C ++中的acos()函數(shù)以弧度形式返回?cái)?shù)字(參數(shù))的反余弦值。

此函數(shù)在<cmath>頭文件中定義。

[數(shù)學(xué)] cos-1x = acos(x) [C++];

acos()原型[從C ++ 11標(biāo)準(zhǔn)開(kāi)始]

double acos(double x);
float acos(float x);
long double acos(long double x);
double acos (T x); //為整型

acos()參數(shù)

acos()函數(shù)采用[-1,1]范圍內(nèi)的單個(gè)強(qiáng)制性參數(shù)。這是因?yàn)橛嘞抑翟?到-1的范圍內(nèi)。

acos()返回值

假設(shè)參數(shù)在[-1,1]范圍內(nèi),則acos()函數(shù)返回[0,π]范圍內(nèi)的值。

如果參數(shù)大于1或小于-1,則acos()返回,NaN即不是數(shù)字。

參數(shù)(x)返回值
x = [-1,1][0,π]以弧度為單位
-1> x或x> 1NaN(非數(shù)字)

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

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  double x = 0.0, result;

  result = acos(x);
  cout << "acos(x) = " << result << " radians" << endl;
  
  cout << "acos(x) = " << result*180/3.1415 << " degrees" << endl;
  
  return 0;
}

運(yùn)行該程序時(shí),輸出為:

acos(x) = 1.5708 radians
acos(x) = 90.0027 degrees

示例2:具有整數(shù)類型的acos()函數(shù)

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  int x = -1;
  double result;

  result = acos(x);
  
  cout << "acos(x) = " << result << " radians" << endl;
  // 將結(jié)果轉(zhuǎn)換為角度
  cout << "acos(x) = " << result*180/3.1415 << " degrees";
  
  return 0;
}

運(yùn)行該程序時(shí),輸出為:

acos(x) = 3.14159 radians
acos(x) = 180.005 degrees

  C++ 庫(kù)函數(shù) <cmath>