c++ 如何開N次方?速解

直接上代碼
#include <iostream> #include <cmath> using namespace std; typedef long long LL; int main() { LL a = 625; LL s = pow(a,1.0/4); cout<<"pow開方:"<<s<<endl; return 0; }
說明一下:
- pow中的第二個參數必須是1.0 / N,或者 1 / N.0的結構,1/4這樣的都是整數,開平方開不出來。
#include <iostream> #include <cmath> using namespace std; typedef long long LL; int main() { LL a = 625; LL s = pow(a,1.0/4); cout<<"pow開方:"<<s<<endl; return 0; }
說明一下:
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。