C ++ atan () - biblioteka standardowa C ++

Funkcja atan () w C ++ zwraca odwrotną tangens do liczby (argumentu) w radianach.

Ta funkcja jest zdefiniowana w pliku nagłówkowym.

(Matematyka) tan -1 x = atan (x) (W programowaniu w C ++);

atan () prototyp (w standardzie C ++ 11)

podwójny atan (podwójne x); float atan (float x); długi podwójny atan (długi podwójny x); podwójny atan (T x); // Dla typu całkowitego

atan () Parametry

Funkcja atan () przyjmuje jeden obowiązkowy argument (może być dodatni, ujemny lub zerowy)

atan () Zwracana wartość

Funkcja atan () zwraca wartość z zakresu (-π / 2, π / 2) .

Przykład 1: Jak działa 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; )

Po uruchomieniu programu wynik będzie następujący:

 atan (x) = 1,55348 radianów atan (x) = 89,0104 stopni

Przykład 2: funkcja atan () z typem całkowitym

 #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; )

Po uruchomieniu programu wynik będzie następujący:

 atan (x) = 1,49949 radianów atan (x) = 85,9169 stopni

Interesujące artykuły...