C ++ atan () - C ++ standardní knihovna

Funkce atan () v C ++ vrací inverzní tangens čísla (argumentu) v radiánech.

Tato funkce je definována v hlavičkovém souboru.

(Mathematics) tan -1 x = atan (x) (V programování v C ++);

atan () prototyp (podle standardu C ++ 11)

dvojitý atan (dvojitý x); float atan (float x); dlouhý dvojitý atan (dlouhý dvojitý x); dvojitý atan (T x); // Pro integrální typ

atan () Parametry

Funkce atan () přebírá jeden povinný argument (může být kladný, záporný nebo nulový)

atan () Návratová hodnota

Funkce atan () vrací hodnotu v rozsahu (-π / 2, π / 2) .

Příklad 1: Jak funguje 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; )

Když spustíte program, výstup bude:

 atan (x) = 1,55348 radiánů atan (x) = 89,0104 stupňů

Příklad 2: Funkce atan () s integrálním typem

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

Když spustíte program, výstup bude:

 atan (x) = 1,49949 radiánů atan (x) = 85,9169 stupňů

Zajímavé články...