精品丰满熟女一区二区三区_五月天亚洲欧美综合网_亚洲青青青在线观看_国产一区二区精选

  • <menu id="29e66"></menu>

    <bdo id="29e66"><mark id="29e66"><legend id="29e66"></legend></mark></bdo>

  • <pre id="29e66"><tt id="29e66"><rt id="29e66"></rt></tt></pre>

      <label id="29e66"></label><address id="29e66"><mark id="29e66"><strike id="29e66"></strike></mark></address>
      學(xué)習(xí)啦 > 學(xué)習(xí)英語 > 專業(yè)英語 > 計(jì)算機(jī)英語 > c語言pow的用法

      c語言pow的用法

      時(shí)間: 長(zhǎng)思709 分享

      c語言pow的用法

        C語言中pow函數(shù)用于計(jì)算x的y次冪。下面我們來看看c語言pow的用法。
        pow函數(shù)有以下幾種的重載形式:
        double pow(double X,int Y);
        float pow(float X,float Y);
        float pow(float X,int Y);
        long double pow(long double X,long double Y);
        long double pow(long double X,int Y);
        使用的時(shí)候應(yīng)合理設(shè)置參數(shù)類型,避免有多個(gè)“pow”實(shí)例與參數(shù)列表相匹配的情況。
        其中較容易發(fā)生重載的是使用形如:
        int X,Y;
        int num=pow(X,Y);
        這是一個(gè)比較常用的函數(shù),但是編譯器會(huì)提醒有多個(gè)“pow”實(shí)例與參數(shù)列表相匹配。
        可以使用強(qiáng)制類型轉(zhuǎn)換解決這個(gè)問題:num=pow((float)X,Y)
        原型:extern float pow(float x, float y);
        用法:#include
        功能:計(jì)算x的y次冪。
        說明:x應(yīng)大于零,返回冪指數(shù)的結(jié)果。
        舉例:
        // pow.c
        #include
        #include
        #include
        void main()
        {
        printf("4^5=%f",pow(4.,5.));
        getchar();
        }
        #include
        #include
        void main( void )
        {
        double x = 2.0, y = 3.0, z;
        z = pow( x, y );
        printf( "%.1f to the power of %.1f is %.1f ", x, y, z );
        }
        Output
        2.0 to the power of 3.0 is 8.0
      512952