mnbn.net
当前位置:首页 >> 一元二次方程程序 >>

一元二次方程程序

步骤: 打开visual C++ 6.0-文件-新建-文件-C++ Source File 2. 定义变量: #include #include void main() { double a,b,c; /*定义系数变量*/ double x1,x2,p; /*定义根变量和表达式的变量值*/ 3.输入系数: printf("请输入a,b,c:"); /*提示用...

#include "stdio.h" #include "math.h" void main() { float a,b,c; scanf("%f%f%f",&a,&b,&c); float temp=sqrt(b*b-4*a*c); if(temp

C语言编写一程序求解一元二次方程的根: #include #include void m(float a,float b,float c) { double x1,x2; x1=(-b+sqrt(b*b-4*a*c))/(2*a); x2=(-b-sqrt(b*b-4*a*c))/(2*a); printf("方程的根是%.2lf和%.2lf",x1,x2); } void n(float a,floa...

#include#includevoid main(){ double a,b,c,d,x1,x2; /*sqrt要求用double型,定义用double,另外double和后面变量之间要有空格*/ printf("请输入系数a、b、c:"); scanf("%lf%lf%lf",&a,&b,&c); /*&b和&c之间要有逗号*/ d=b*b-4*a*c; x1=(-b+sqr...

#include #include #include void main() { float a,b,c; float result1; float result2; printf("input a,b,c"); scanf("%f,%f,%f", &a, &b, &c); if (sqr(b)-4*a*c > 0) { result1 = (-1 * b + sqrt(sqr(b)-4*a*c))/(2*a); result2 = (-1 * b ...

/*March 25 2014 By 12052010 * TODO: 计算简单的 一元二次方程式的根 */#include #includeint main(){int a,b,c;int fg;do{printf("\nInput a,b,c:");//输进数字时,采用逗号分隔开来,如:1,2,3 ,且a!=0 scanf("%d,%d,%d",&a,&b,&c);}while (a==0...

double x1 = 0;//解1double x2 = 0;//解2Console.WriteLine("求 ax^2+bx+c=0 的解");Console.Write("请输入a的值:");double a = Convert.ToInt32(Console.ReadLine());Console.Write("请输入b的值:");double b = Convert.ToInt32(Console.Read...

#include #include int main(void) { double a,b,c,x1,x2,d; scanf("%lf%lf%lf",&a,&b,&c); d = b * b - 4 * a * c; if(d > 0) { x1 = (-1 * b + sqrt(d)) / (2 * a); x2 = (-1 * b - sqrt(d)) / (2 * a); printf("x1 = %g,x2 = %g\n",x1,x2); }...

给个算法的框架,你可以自己细化。 #include "math.h" float a, b, c, delta; scanf("%f,%f,%f", &a, &b, &c); delta=b*b-4*a*c; if(delta==0) { printf("Result is %5.2f\n", -b/(2*a)); } else if(delta >0) { printf("Result is %5.2f, %5.2f...

import java.util.Scanner; public class Demo { public static void main(String [] args){ Scanner sc = new Scanner(System.in); System.out.println("输入2次方的系数"); int a = sc.nextInt(); System.out.println("输入1次方的系数"); in...

网站首页 | 网站地图
All rights reserved Powered by www.mnbn.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com