本文目錄一覽:
用c語言怎樣求自然常數e
代碼如下
:
運行過了
輸出e=2.718282
不知是否滿意
望採納
#include
void
main(){
long
fun(int
n);
int
i;
double
e=0;
double
eps=1e-6;//eps表示精度
此處指10的-6次方
for(i=0;1.0/fun(i)eps;i++)
{
e+=1.0/fun(i);
}
printf(“e=%lf\n”,e);
}
long
fun(int
n)//求n!的函數
{
if(n==0)
return
1;
else
return
n*fun(n-1);
}
求助:用C語言表示自讓常數e
以下程序沒有經過調試(我在網吧,沒帶編譯器),但多少可提供思路
#include “math.h”
void main()
{
double e;
unsigned int n=65535;//用65535表示數學意義上的『無窮大』
e=1+1/n;
e=pow(e,n); //pow(double x,double n)表示求X的N次方
printf(“%f”,pow(e,2.567));
getch();
}
急求!怎樣在C語言編程中表示自然數e?
只能自己手動用具體數來表示
比如
const double e=2.71828;
或者
#define e 2.71828
huliyuputao 是正解
C語言中怎麼調用自然對數e的值
好像沒有定義e的常數。也不好定義,因為它是無限不循環小數。可以寫一個函數自己求得需要精度的e,舉例如下:
double mye(void){
double e=1.0,n=1.0;
int i=1;
while(1/n1.0E-10){
e+=1/n;
n*=++i;
}
return e;
}
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/253343.html