Funkcija atan () C ++ atgriež skaitļa (argumenta) apgriezto tangensu radiānos.
Šī funkcija ir definēta galvenes failā.
(Matemātika) tan -1 x = atan (x) (C ++ programmēšanā);
atan () prototips (pēc standarta C ++ 11)
dubultā atan (dubultā x); pludiņš atāns (pludiņš x); garš dubultā atan (garš dubultā x); dubultā atāns (T x); // Neatņemamajam tipam
atan () Parametri
Funkcijai atan () ir nepieciešams viens obligāts arguments (var būt pozitīvs, negatīvs vai nulle)
atan () Atgriešanās vērtība
Funkcija atan () atgriež vērtību diapazonā (-π / 2, π / 2) .
1. piemērs: Kā darbojas atan ()?
#include #include using namespace std; int main() ( double x = 57.74, result; result = atan(x); cout << "atan(x) = " << result << " radians" << endl; // Output in degrees cout << "atan(x) = " << result*180/3.1415 << " degrees" << endl; return 0; )
Palaidot programmu, izeja būs:
atan (x) = 1,55348 radiāni atan (x) = 89,0104 grādi
2. piemērs: funkcija atan () ar integrālo tipu
#include #include #define PI 3.141592654 using namespace std; int main() ( int x = 14; double result; result = atan(x); cout << "atan(x) = " << result << " radians" << endl; // Output in degrees cout << "atan(x) = " << result*180/3.1415 << " degrees" << endl; return 0; )
Palaidot programmu, izeja būs:
atan (x) = 1,49949 radiāni atan (x) = 85,9169 grādi