<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # C++ 程序:計算數字的冪 > 原文: [https://www.programiz.com/cpp-programming/examples/power-number](https://www.programiz.com/cpp-programming/examples/power-number) #### 在本文中,您將學習通過使用`pow()`函數手動計算數字的冪。 要理解此示例,您應該了解以下 [C++ 編程](/cpp-programming "C++ tutorial")主題: * [C++ `while`和`do...while`循環](/cpp-programming/do-while-loop) * * * 該程序從用戶處獲得兩個數字(一個基本數字和一個指數)并計算功效。 ```cpp Power of a number = baseexponent ``` * * * ### 示例 1:手動計算冪 ```cpp #include <iostream> using namespace std; int main() { int exponent; float base, result = 1; cout << "Enter base and exponent respectively: "; cin >> base >> exponent; cout << base << "^" << exponent << " = "; while (exponent != 0) { result *= base; --exponent; } cout << result; return 0; } ``` **輸出** ```cpp Enter base and exponent respectively: 3.4 5 3.4^5 = 454.354 ``` 僅當指數為正整數時,以上技術才有效。 如果需要以任何實數為指數的整數冪,可以使用`pow()`函數。 * * * ## 示例 2:使用`pow()`函數計算冪 ```cpp #include <iostream> #include <cmath> using namespace std; int main() { float base, exponent, result; cout << "Enter base and exponent respectively: "; cin >> base >> exponent; result = pow(base, exponent); cout << base << "^" << exponent << " = " << result; return 0; } ``` **輸出** ```cpp Enter base and exponent respectively: 2.3 4.5 2.3^4.5 = 42.44 ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看