#include stdio.h
成都創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),高陽(yáng)企業(yè)網(wǎng)站建設(shè),高陽(yáng)品牌網(wǎng)站建設(shè),網(wǎng)站定制,高陽(yáng)網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,高陽(yáng)網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
#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ì)改程序
void fun(double *in, double *out)
{
while (1)
{
*out = (*in);
if (50 == *in)
{
break;
}
*in = *out;
}
}
#include?stdio.h?
int?main()?
{double?x,y;
scanf("%lf",x);
if(x0)y=x*x-1;
else?if(x1)y=x*x;
else?y=x*x+1;
printf("%g",y);
return?0;?
}
就寫(xiě)個(gè)函數(shù)嘛
輸入一個(gè)x,然后調(diào)用函數(shù)
int fun(int x)
{
return 4 *x * x * x + 6 * x * x - 3 * x;
}
就可以了
#include?stdio.h
#include?math.h
#define?PI?3.1415926
int?main()
{
double?x,y;
scanf("%lf",x);
y=abs(pow(x,2)-7*exp(x))+sqrt(3*pow(x,2)+PI*sin(67*PI/180)/2);
printf("%lf",y);
return?0;
}
#includestdio.h
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改為定植 望采納 謝謝