#include<iostream>
#include<cmath>
#include<fstream>
using namespace std;
void eqn_quad(float a,float b,float c);
int mian()
{
int table[4][3],i,j;
ifstream is;
ofstream os;
is.open("score.txt");
for(i=0;i<4;i++)
{
for(j=0;j<3;j++)
{
is >> table[i][j];
}
}
for(i=0;i<4;i++)
{
eqn_quad(table[i][0],table[i][1],table[i][2]);
}
is.close();
return 0;
}
void eqn_quad(float a,float b,float c)
{
double result1=0,result2=0;
double d=0;
result1=(-b+sqrt(b*b-4*a*c))/(2*a);
result2=(-b-sqrt(b*b-4*a*c))/(2*a);
d=(b*b)-(4*a*c);
if(d>0)
{
cout<<"두개의실근"<<result1<<result2<<"를 가집니다"<<endl;
}
if(d==0)
{
cout<<"중근을 가집니다."<<endl;
}
if(d<0)
{
cout<<"허근을 가집니다."<<endl;
}
}
float에서 int가 변형안된다고하는데 어떻하죠 ㅠㅠ
int 로하고싶어도 sqrt떄문에 int형으로하면안되구
float으로하고싶어도 table[i][j]가 float으로 안되고
뭘바꿔야하나여
캐스팅.