1、C語言中,有兩個log函數(shù),分別為log10和log函數(shù),具體用法如下:
堅守“ 做人真誠 · 做事靠譜 · 口碑至上 · 高效敬業(yè) ”的價值觀,專業(yè)網(wǎng)站建設(shè)服務(wù)10余年為成都木屋小微創(chuàng)業(yè)公司專業(yè)提供企業(yè)網(wǎng)站設(shè)計營銷網(wǎng)站建設(shè)商城網(wǎng)站建設(shè)手機網(wǎng)站建設(shè)小程序網(wǎng)站建設(shè)網(wǎng)站改版,從內(nèi)容策劃、視覺設(shè)計、底層架構(gòu)、網(wǎng)頁布局、功能開發(fā)迭代于一體的高端網(wǎng)站建設(shè)服務(wù)。
2、函數(shù)名: log10
功 能: 對數(shù)函數(shù)log,以10為底
用 法: double log10(double x);
程序示例:
#include math.h
#include stdio.hint main(void)
{
double result;
double x = 800.6872;
result = log10(x);
printf("The common log of %lf is %lf\n", x, result);
return 0;
}
3、函數(shù)名: log
功 能: 對數(shù)函數(shù)log,以e(2.71828)為底
用 法: double log(double x);
程序示例:
#include math.h
#include stdio.hint main(void)
{
double result;
double x = 800.6872;
result = log(x);
printf("The common log of %lf is %lf\n", x, result);
return 0;
}
#include?stdio.h
#include?math.h
void?main()
{
float?x;
scanf("%f",x);
(x=(float)0)?printf("輸入有誤!"):printf("lgx=%f",log10(x));
}
運行示例截圖:
表示為log10(1.5)即可。lg1.5中的lg是數(shù)學(xué)中以10為底的對數(shù)函數(shù)的一種書寫表示,在C語言中對應(yīng)的庫函數(shù)名是log10。比如:
//#include "stdafx.h"http://If the vc++6.0, with this line.
#include "stdio.h"
#include "math.h"http://log10在這個頭文件中
int main(void){
printf("lg1.5 = %g\n",log10(1.5));
return 0;
}輸出是lg1.5
=
0.176091
網(wǎng)頁標(biāo)題:c語言中l(wèi)g函數(shù)怎么寫 c語言lg函數(shù)怎么調(diào)用
網(wǎng)站鏈接:http://vcdvsql.cn/article48/ddcocep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設(shè)計公司、服務(wù)器托管、軟件開發(fā)、App開發(fā)、做網(wǎng)站、App設(shè)計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)