编写一个程序来计算一个qudratic eqation的实根,根由公式x1 = -b +√b2-4ac/ 2a x2 = -b-√b2-4ac/ 2a给出 [英] Write a programm to compute the real roots of a qudratic eqation the roots are givenby the equation x1=-b+√b2-4ac/2a x2=-b-√b2-4ac/2a

查看:411
本文介绍了编写一个程序来计算一个qudratic eqation的实根,根由公式x1 = -b +√b2-4ac/ 2a x2 = -b-√b2-4ac/ 2a给出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

程序应该请求constanta,b和c的值并打印x1和x2的值使用以下规则

如果a和b都为零则没有解决方案

只有一个根,如果a = 0(x = -c / b)

如果b2-4ac为负则没有真正的根源

否则有是2个真正的根源



我尝试过:



the programm should request for the values of the constanta,b and c and print the values of x1 and x2 use the following rules
no solution if both a and b are zero
there is only one root if a=0 (x=-c/b)
there are no real roots if b2-4ac is negative
otherwise there are 2 real roots

What I have tried:

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,x1,x2,xr,xi,dis;
printf("enter the number\n");
scanf("%f%f%f",&a,&b,&c);
if(a==0&&b==0);
{
else if(a==0)
}
x=-c/b;
printf("only one root is exists");
printf("the value of x=%f",x);

推荐答案

我们不做你的作业:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



如果遇到具体问题,请询问相关问题,我们会尽力提供帮助。但是我们不会为你做这一切!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!


获得一个更现代的编译器。

你的程序有一些错误,我修复了那些,现在你必须完成它

Get a more modern compiler.
You program had some bugs, iI fixed those, now you have to complete it
#include <stdio.h>
#include <math.h>

int main()
{
  double a, b, c;
  printf("plaease enter the coefficients\n");
  scanf("%lf %lf %lf",&a,&b,&c);
  if( a == 0.0 )
  {
    if ( b == 0.0)
    {
      printf("sorry, no roots\n");
    }
    else
    {
      double x = - c / b;
      printf("only one root is exists: %f\n",  x);
    }
  }
  else
  { // here a != 0.0
    // ...
  }
  return 0;
}


这篇关于编写一个程序来计算一个qudratic eqation的实根,根由公式x1 = -b +√b2-4ac/ 2a x2 = -b-√b2-4ac/ 2a给出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆