二次方程求解器 [英] Quadratic equation solver

查看:89
本文介绍了二次方程求解器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要求用户输入系数a,b和c。然后让你的程序解决X的两个(或可能是一个)解决方案。小心确保有一个解决方案,确认平方根没有被执行在被认为是虚数的负数上。 />

一定要#include< cmath>并在进行数学计算时调用pow()和sqrt()函数。还要注意,系数ab和c将被声明为double,以及你的两个X解决方案。

这是我到目前为止所做的:

Ask the user to enter the coefficients a, b and c. Have your program then solve the two (or possibly one) solution(s) for X. Be careful to make sure there is a solution by confirming that the square root is not executed on a negative number which is considered to be imaginary.

Be sure to #include<cmath> and call the pow() and sqrt() functions when making your math calculations. Also note, the coefficients a b and c are to be declared as a double, as well as your two solutions for X.
this is what i did so far:

展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号

推荐答案

我假设您的程序试图求解二次方程。

请详细说明您所面临的问题。从问题描述我根本无法解决任何问题!!


这里有一些指示:

1)你还没有声明a,b ,c为double。

2)声明''check''为double,或者sqrt()会抱怨模糊的电话。


这样做然后告诉我们你到底陷入困境的确切位置。


最重要的是,不要忘记将代码片段放在代码标签中。
I am assuming your program attempts to solve a quadratic equation.
please mention the issue you are facing in more details. From the problem description i could not make out any issues at all !!

Here are a few pointers:
1) You have not declared a,b,c as double.
2) Declare ''check'' as double as well or sqrt() will complain of an ambiguous call.

Do this and then let us know exactly where you are getting stuck.

And , most important , don''t forget to put your code snippets inside the code-tags.


我不知道如何输出应该是这样的,因为从我得到它显示这个:

上次登录:2月25日星期二21:57:40在ttys000

/体积/ JOANNEKEO / C ++ 1.5 / HWkeoAssignment2-3A

joanne-keos-macbook:~joanne
i don''t know how the output should look like because from what i get it shows this:
Last login: Thu Feb 25 21:57:40 on ttys000
/Volumes/JOANNEKEO/C++1.5/HWkeoAssignment2-3A
joanne-keos-macbook:~ joanne


/Volumes/JOANNEKEO/C++1.5/HWkeoAssignment2-3A
输入a的值:5

输入b的值:6

输入c的值:3

joanne-keos-macbook:~joanne
/Volumes/JOANNEKEO/C++1.5/HWkeoAssignment2-3A
Enter the value of a: 5
Enter the value of b: 6
Enter the value of c: 3
joanne-keos-macbook:~ joanne


这篇关于二次方程求解器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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