www.5129.net > C语言编程序 计算3X2%5X+1=0的根

C语言编程序 计算3X2%5X+1=0的根

#include "stdio.h" #include "math.h" double x1,x2,p;float file1(float a,float b) { x1=(-b+sqrt(p))/2*a;x2=(-b-sqrt(p))/2*a;return 0; } float file2(float a,float b) { x1=x2=(-b+sqrt(p))/2*a; return 0; } void main() { float a=3,b...

写这样的程序,最主要是要知道用什么函数表示变量的几次方,这个函数在头文件math.h里,如果是自然底数e,的多少次方,就用函数exp,参数就是几次方,比如exp(x),就表示e的x次方,所以这个函数如下: #include #include main() { double x=2....

float x,y; printf("qingshuru-x/n"); scanf("%f",&x); if(x>0){ y=2*x; }else{ y=x*x+3*x-5; } printf("y=%f",y);

#include "stdio.h"int main(int argc,char *argv[]){double x,t;for(x=2.3;x-0.000001 && t2.7)printf("There is no solution...\n");return 0;}

#include #include "math.h"int main(int argc,char *argv[]){ double t=-5/4.0,s=5*5-4.0*2*3; if(s>=0){ s=sqrt(s); printf("x1 = %f x2 = %f\n",t+s/4.0,t-s/4.0); } else printf("No solution\n"); return 0;}

#include "stdio.h" #include "math.h" int main() { float a,b,c,x1,x2,d; printf("请输入a:"); scanf("%f",&a); printf("请输入b:"); scanf("%f",&b); printf("请输入c:"); scanf("%f",&c); d=b*b-4*a*c; if(d < 0) printf("此方程没有实数...

正根2.414,用卡尔丹公式证明,另:负根是0.414,-2 代码: int main() { double a=0,x=0; do { x = x+0.001; a = x*x*x-5*x-2 ; if(a > 0) { } else { a =(0-a); } }while(a > 0.003); printf("%f\n",x); return 0; }

参考代码如下: #include#includedouble f(double x);int main() {double x;printf("Please input X=");scanf("%lf",&x);printf("f(x)=%f",f(x));}double f(double x){return 5*pow(x,5)-10*pow(x,4)+23*pow(x,3)+15*x-30;}执行效果如下:

#include "stdio.h" #include "math.h" main() { float a,b,c,x1,x2,d; printf("请输入a:"); scanf("%f",&a); printf("请输入b:"); scanf("%f",&b); printf("请输入c:"); scanf("%f",&c); d=b*b-4*a*c; if(d0) { x1=(-b+sqrt(d))/(2*a); x2=(...

#include “sdtio.h” main() { int x; printf("请输入X的值:"); scanf("%d",&x); if(x=2&&x10) printf("Y=%d",5*x+1) else if(x==10) printf("Y=%d或者Y=",5*x-1,5*x+1); getch(); }

网站地图

All rights reserved Powered by www.5129.net

copyright ©right 2010-2021。
www.5129.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com