
- C 標準庫
- C 標準庫
- C++ 標準庫
- C++ 庫 - 首頁
- C++ 庫 - <fstream>
- C++ 庫 - <iomanip>
- C++ 庫 - <ios>
- C++ 庫 - <iosfwd>
- C++ 庫 - <iostream>
- C++ 庫 - <istream>
- C++ 庫 - <ostream>
- C++ 庫 - <sstream>
- C++ 庫 - <streambuf>
- C++ 庫 - <atomic>
- C++ 庫 - <complex>
- C++ 庫 - <exception>
- C++ 庫 - <functional>
- C++ 庫 - <limits>
- C++ 庫 - <locale>
- C++ 庫 - <memory>
- C++ 庫 - <new>
- C++ 庫 - <numeric>
- C++ 庫 - <regex>
- C++ 庫 - <stdexcept>
- C++ 庫 - <string>
- C++ 庫 - <thread>
- C++ 庫 - <tuple>
- C++ 庫 - <typeinfo>
- C++ 庫 - <utility>
- C++ 庫 - <valarray>
- C++ STL 庫
- C++ 庫 - <array>
- C++ 庫 - <bitset>
- C++ 庫 - <deque>
- C++ 庫 - <forward_list>
- C++ 庫 - <list>
- C++ 庫 - <map>
- C++ 庫 - <multimap>
- C++ 庫 - <queue>
- C++ 庫 - <priority_queue>
- C++ 庫 - <set>
- C++ 庫 - <stack>
- C++ 庫 - <unordered_map>
- C++ 庫 - <unordered_set>
- C++ 庫 - <vector>
- C++ 庫 - <algorithm>
- C++ 庫 - <iterator>
- C++ 高階庫
- C++ 庫 - <any>
- C++ 庫 - <barrier>
- C++ 庫 - <bit>
- C++ 庫 - <chrono>
- C++ 庫 - <cinttypes>
- C++ 庫 - <clocale>
- C++ 庫 - <condition_variable>
- C++ 庫 - <coroutine>
- C++ 庫 - <cstdlib>
- C++ 庫 - <cstring>
- C++ 庫 - <cuchar>
- C++ 庫 - <charconv>
- C++ 庫 - <cfenv>
- C++ 庫 - <cmath>
- C++ 庫 - <ccomplex>
- C++ 庫 - <expected>
- C++ 庫 - <format>
- C++ 庫 - <future>
- C++ 庫 - <flat_set>
- C++ 庫 - <flat_map>
- C++ 庫 - <filesystem>
- C++ 庫 - <generator>
- C++ 庫 - <initializer_list>
- C++ 庫 - <latch>
- C++ 庫 - <memory_resource>
- C++ 庫 - <mutex>
- C++ 庫 - <mdspan>
- C++ 庫 - <optional>
- C++ 庫 - <print>
- C++ 庫 - <ratio>
- C++ 庫 - <scoped_allocator>
- C++ 庫 - <semaphore>
- C++ 庫 - <source_location>
- C++ 庫 - <span>
- C++ 庫 - <spanstream>
- C++ 庫 - <stacktrace>
- C++ 庫 - <stop_token>
- C++ 庫 - <syncstream>
- C++ 庫 - <system_error>
- C++ 庫 - <string_view>
- C++ 庫 - <stdatomic>
- C++ 庫 - <variant>
- C++ STL 庫速查表
- C++ STL - 速查表
- C++ 程式設計資源
- C++ 程式設計教程
- C++ 有用資源
- C++ 討論
C++ Valarray::atan 函式
valarray 類中的 atan() 函式用於建立一個 valarray,其元素計算為原始 valarray 中每個元素的 tan-1。
cmath 中的 atan() 函式在此函式中被過載,它為每個元素呼叫一次。Atan() 返回範圍 [-x/2,x/2] 內的值,並且與所有實數相容。
語法
以下是 C++ Valarray::atan 函式的語法:-
atan (const valarray<T>& x);
引數
x - 它包含一個型別的元素,對於該型別,定義了單目函式 atan。
示例
示例 1
讓我們來看下面的例子,我們將輸入一個數字,將其傳遞給 atan() 函式並檢索輸出。
#include <iostream> #include <cmath> using namespace std; int main() { double x =12.43,result; result =atan (x); cout << "atan(""<<x<<"") = " << result << endl; return 0; }
輸出
讓我們編譯並執行上述程式,這將產生以下結果:-
atan(<x<) = 1.49052
示例 2
以下是一個示例,我們將使用 atan() 函式並檢索原始 valarray 和 atan valarray 的輸出。
#include <iostream> #include <valarray> using namespace std; int main() { valarray<double> myvalarray = { 1.2, -0.6, 4, -5.67, -2 }; cout << "The Orignal Valarray : "; for (double& ele : myvalarray) cout << ele << " "; valarray<double> atanvalarray = atan(myvalarray); cout << "\nThe atan Valarray : "; for (double& ele : atanvalarray) cout << ele << " "; return 0; }
輸出
讓我們編譯並執行上述程式,這將產生以下結果:-
The Orignal Valarray : 1.2 -0.6 4 -5.67 -2 The atan Valarray : 0.876058 -0.54042 1.32582 -1.39622 -1.10715
示例 3
考慮另一種情況,我們將使用 atan() 函式並以度為單位檢索輸出。
#include <iostream> #include <cmath> #define PI 3.141592654 using namespace std; int main() { int a = 25; double result; result = atan(a); cout << "atan(a) = " << result*180/3.1415 << " degrees" << endl; return 0; }
輸出
讓我們編譯並執行上述程式,這將產生以下結果:-
atan(a) = 87.712 degrees
示例 4
在下面的示例中,我們將使用 atan() 函式並以弧度為單位檢索輸出。
#include <iostream> #include <cmath> using namespace std; int main() { double x = 142.5; double resultRadians = atan(x); cout << "atan(x) = " << resultRadians << " radians" << endl; return 0; }
輸出
讓我們編譯並執行上述程式,這將產生以下結果:-
atan(x) = 1.56378 radians
廣告