dd

dd


#include <iostream>


using namespace std; 


void f(float , float , float ); 


void g(int n);



int main()

{

//setlocale(LC_ALL, "russ");

float x1, x2, x3;

int n;

cout << "Vvdetite kol-vo"<< endl;

cin >> n;

g(n);




//cout << "vvidice a,b,c"<< endl;

//cin >> x1 >> x2 >> x3;

//cout << "a = " << x1 << " b= " << x2 << " c= " << x3<<endl;

//f(x1, x2, x3);

return 0;

}



void f(float a, float b, float c) {

float x1, x2, x3, x4, t1, t2,d;

d = (b*b) - 4 * a*c;

if (d < 0)

cout << "net korney" << endl;

else

{

t1 = (-b + sqrt(d)) / (2 * a);//находим корни t1

t2 = (-b - sqrt(d)) / (2 * a);//находим корни t2


if ((t1 > 0) && (t2 > 0)) //4 действительных корня

{

cout << "4 deistvitely korny" << endl;

x1 = sqrt(t1);//находим корень x1

x2 = -sqrt(t1);//находим корень x2

x3 = sqrt(t2);//находим корень x3

x4 = -sqrt(t2);//находим корень x4

cout << "x1=" << x1 << endl;

cout << "x2=" << x2 << endl;

cout << "x3=" << x3 << endl;

cout << "x4=" << x4 << endl;

}


else if ((t1 > 0) && (t2 < 0))//2 действительных корня

{

cout << "2 deistvitely korny" << endl;

x1 = sqrt(t1);//находим корень x1

x2 = -sqrt(t1);//находим корень x2

cout << "x1=" << x1 << endl;

cout << "x2=" << x2 << endl;

}


else  if ((t1 < 0) && (t2 > 0))//2 действительных корня

{

cout << "2 deistvitely korny" << endl;

x3 = sqrt(t2);//находим корень x1

x4 = -sqrt(t2);//находим корень x2

cout << "x1=" << x3 << endl;

cout << "x2=" << x4 << endl;

}


else if ((t1 < 0) && (t2 < 0))

cout << "net deystvity korney" << endl;

}

}



void g(int n) {

float a1, b1, c1;

for (int i = 1; i <= n; i++) {

cout << "Vvdedi kovitenc" << endl;

cin >> a1 >> b1 >> c1;

f(a1, b1, c1);

}



}


Report Page