sajjadrad
شنبه 28 فروردین 1389, 00:02 صبح
سلام دوستان
این برنامه پیدا کردن دو ریشه یه معادله هست...اما نمیدونم چرا موقع کامپایل خطا میده...خطا رو ضمیمه کردم
سورس برنامه:
#include <iostream>
#include <cmath>
void find_stem (int,int,int,int&,float&,float&);
int main ()
{
int a,b,c;
int d=1;
float x1,x2;
cout<<"enter 3 integers number for a,b,c :"<<endl;
cin>>a>>b>>c;
cout<<"your equation is : "<<a<<"x*x+"<<b<<"x+"<<c<<endl;
find_stem(a,b,c,d,x1,x2);
if (d)
cout<<"your equation have two stem : "<<"x1="<<x1<<" and x2="<<x2;
else cout<<"your equation have one stem : "<<"x="<<x1;
return 0;
}
//************************************************** ************************************
void find_stem (int a,int b,int c,int& d,float& x1,float& x2);
{
int delta=(b*b)-(4*a*c);
if ( delta<0 )
{
cout<<"your equation have not stem.";
exit(1);
}
if (delta==0)
{
x1=(-b)/(2*a);
d=0;
}
else
{
float sqrt_delta = sqrt(delta);
x1=(-b+sqrt_delta)/(2*a);
x2=(-b-sqrt_delta)/(2*a);
}
}
این برنامه پیدا کردن دو ریشه یه معادله هست...اما نمیدونم چرا موقع کامپایل خطا میده...خطا رو ضمیمه کردم
سورس برنامه:
#include <iostream>
#include <cmath>
void find_stem (int,int,int,int&,float&,float&);
int main ()
{
int a,b,c;
int d=1;
float x1,x2;
cout<<"enter 3 integers number for a,b,c :"<<endl;
cin>>a>>b>>c;
cout<<"your equation is : "<<a<<"x*x+"<<b<<"x+"<<c<<endl;
find_stem(a,b,c,d,x1,x2);
if (d)
cout<<"your equation have two stem : "<<"x1="<<x1<<" and x2="<<x2;
else cout<<"your equation have one stem : "<<"x="<<x1;
return 0;
}
//************************************************** ************************************
void find_stem (int a,int b,int c,int& d,float& x1,float& x2);
{
int delta=(b*b)-(4*a*c);
if ( delta<0 )
{
cout<<"your equation have not stem.";
exit(1);
}
if (delta==0)
{
x1=(-b)/(2*a);
d=0;
}
else
{
float sqrt_delta = sqrt(delta);
x1=(-b+sqrt_delta)/(2*a);
x2=(-b-sqrt_delta)/(2*a);
}
}