问题描述
大家好!
我是c编程的新生,我们得到了一个创建程序的任务,该程序吐出了二次方程的根源!
我试了一下,但似乎错了,这就是为什么我需要你的帮助!谢谢
公式为x =( - 1/2)* p + - sqrt(1/4)* p ^ 2 -q)及其(p, q)是我的数据。如果等式没有真正的根printf(它没有真正的根);
我的代码
通过调用来阻止它功能!!
//
//由Haidar Wahid提供
//
//
#pragma warning(禁用:4996)
#include< stdio.h>
#include< stdlib.h>
#include< math.h>
int squareRoot_of(int p,int q,double a); //原型
int main(){
int x,y;
double z;
z = 0.5;
x = 55;
y = 10;
printf("%d \ n%d \ n",squareRoot_of(x,y,z));
系统(暂停);
}
int squareRoot_of(int p,int q,double a)// def
{
return((-a * p)+ - sqrt(a * a * p * p - q));
}
Hi everyone !
i''m a freshmen in c programming, and we got an assignment to create a program that spit out the roots of an quadratic equation!
I''ve given it a try but it seems to be wrong somehow that''s why i need your help! thanks
the formula is x= (-1/2)*p +- sqrt(1/4)*p^2 -q) and its (p,q) is my in-data. if the equation does not have real root printf("itdoes not have real roots");
my code
obs its by calling a function !!
//
// by Haidar Wahid
//
//
#pragma warning (disable:4996)
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
int squareRoot_of(int p, int q, double a); // prototype
int main() {
int x, y;
double z;
z = 0.5;
x = 55;
y = 10;
printf("%d\n%d\n", squareRoot_of(x,y,z));
system("pause");
}
int squareRoot_of(int p, int q, double a) // def
{
return ((-a*p) +- sqrt(a*a*p*p - q));
}
推荐答案
这篇关于二次方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!