C ++ acos () - C ++ Standardbibliothek

Die Funktion acos () in C ++ gibt den inversen Kosinus einer Zahl (Argument) im Bogenmaß zurück.

Diese Funktion ist in der Header-Datei definiert.

(Mathematik) cos -1 x = acos (x) (In C ++ - Programmierung);

acos () Prototyp (Stand C ++ 11 Standard)

Doppel-Acos (Doppel-x); float acos (float x); lange doppelte acos (lange doppelte x); Doppel-Acos (T x); // Für integralen Typ

acos () Parameter

Die Funktion acos () verwendet ein einzelnes obligatorisches Argument im Bereich (-1, 1) . Dies liegt daran, dass der Kosinuswert im Bereich von 1 bis -1 liegt.

acos () Rückgabewert

Da das Argument im Bereich (-1, 1) liegt , gibt die Funktion acos () den Wert im Bereich (0, π) zurück.

Wenn das Argument größer als 1 oder kleiner als -1 ist, gibt acos () NaNkeine Zahl zurück.

Parameter (x) Rückgabewert
x = (-1, 1) (0, π) im Bogenmaß
-1> x oder x> 1 NaN (keine Zahl)

Beispiel 1: Wie funktioniert acos ()?

 #include #include using namespace std; int main() ( double x = 0.0, result; result = acos(x); cout << "acos(x) = " << result << " radians" << endl; // result in degrees cout << "acos(x) = " << result*180/3.1415 << " degrees" << endl; return 0; )

Wenn Sie das Programm ausführen, lautet die Ausgabe wie folgt:

 acos (x) = 1,5708 Bogenmaß acos (x) = 90,0027 Grad

Beispiel 2: acos () -Funktion mit Integraltyp

 #include #include using namespace std; int main() ( int x = -1; double result; result = acos(x); cout << "acos(x) = " << result << " radians" << endl; // Converting result to degrees cout << "acos(x) = " << result*180/3.1415 << " degrees"; return 0; ) 

Wenn Sie das Programm ausführen, lautet die Ausgabe wie folgt:

 acos (x) = 3,14159 Bogenmaß acos (x) = 180,005 Grad

Interessante Beiträge...