#includestdio.h
創(chuàng)新互聯(lián)建站專業(yè)為企業(yè)提供上城網(wǎng)站建設(shè)、上城做網(wǎng)站、上城網(wǎng)站設(shè)計(jì)、上城網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、上城企業(yè)網(wǎng)站模板建站服務(wù),10余年上城做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
float f(float a,float b,float c,float x)
{
float y;
y=a*x*x+b*x+c;
return y;
}
void main()
{
float a,b,c,x;
printf("請(qǐng)輸入a,b,c,x的值\n");
scanf("%f%f%f%f",a,b,c,x);
printf("%f\n",f(a,b,c,x));
}
也可以把a(bǔ),b,c改為定植 望采納 謝謝
#include
int
main()
{
int
n,m;
int
i;
double
s=0;
printf("Please
input
two
numbers.For
example,3,7\n");
scanf("%d
%d",n,m);
for(i=n;i
追問(wèn):
在主函數(shù)中調(diào)用一個(gè)函數(shù)求這個(gè)值怎么搞?
謝謝
評(píng)論
加載更多
簡(jiǎn)單的說(shuō)就是整數(shù)階乘的推廣,它有一個(gè)積分的表達(dá)式:
Γ(x)=∫e^(-t)*t^(x-1)dt (積分的下限式0,上限式+∞)
算法源自《常用算法程序集》徐士良
#include "stdio.h"
double gam1(x)
double x;
{ int i;
double y,t,s,u;
static double a[11]={ 0.0000677106,-0.0003442342,
0.0015397681,-0.0024467480,0.0109736958,
-0.0002109075,0.0742379071,0.0815782188,
0.4118402518,0.4227843370,1.0};
if (x=0.0)
{ printf("err**x=0!\n"); return(-1.0);}
y=x;
if (y=1.0)
{ t=1.0/(y*(y+1.0)); y=y+2.0;}
else if (y=2.0)
{ t=1.0/y; y=y+1.0;}
else if (y=3.0) t=1.0;
else
{ t=1.0;
while (y3.0)
{ y=y-1.0; t=t*y;}
}
s=a[0]; u=y-2.0;
for (i=1; i=10; i++)
s=s*u+a[i];
s=s*t;
return(s);
}
#include stdio.h
#include stdlib.h
//高精度計(jì)算s=1/n+1/(n+1)+1/(n+2)+……+1/m表達(dá)式的值
//求得的s是個(gè)分?jǐn)?shù),分子放在result[0]中,分母放在result[1]中
void func(double *result)
{
int m, n, i;
double *numerator; //分子
printf("Please input n and m (Separate by space and 0nm): \n");
while(scanf("%d%d", n, m))
{
if((0 n) (n m))
break;
printf("Value Invalid, please try again!\n");
printf("Please input n and m (Separate by space and 0nm): \n");
}
numerator = (double *)calloc(m, sizeof(double));
if(!numerator)
{
printf("malloc failed!\n");
exit(0);
}
result[1] = 1;
//下面兩個(gè)for循環(huán)是進(jìn)行通分
for(i=n; i=m; i++)
result[1] *= i;
for(i=n; i=m; i++)
numerator[i-n] = result[1]/i;
result[0] = 0;
//對(duì)分母進(jìn)行相加
for(i=n; i=m; i++)
result[0] += numerator[i-n];
for(i=n; im; i++)
printf("1/%d + ", i);
printf("1/%d = ", m);
free(numerator);
}
int main()
{
double result[2];
func(result);
printf("%g/%g\n", result[0], result[1]);
return 0;
}
//如果你還想對(duì)結(jié)果化為最簡(jiǎn)分?jǐn)?shù)的話,可以告訴我,我會(huì)改程序
網(wǎng)頁(yè)標(biāo)題:c語(yǔ)言利用函數(shù)求值,計(jì)算函數(shù)的值c語(yǔ)言
網(wǎng)頁(yè)URL:http://vcdvsql.cn/article48/hchphp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、手機(jī)網(wǎng)站建設(shè)、小程序開(kāi)發(fā)、微信公眾號(hào)、云服務(wù)器、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)