Code:
#include <iostream>
#include <cmath>
using namespace std;
int main(){
float p, k, l;
float d, x1, x2, y1, y2;
cout << "Upisi koeficijente [p, k, l]:" << endl;
cin >> p >> k >> l;
d=pow((2*k*l-2*p),2)-4*k*k*l*l;
if(d<0)
cout << "Ne sijeku se!" << endl;
else{
x1=((2*p-2*k*l)+sqrt(d))/(2*k*k);
x2=((2*p-2*k*l)-sqrt(d))/(2*k*k);
y1=k*x1+l;
y2=k*x2+l;
if(d==0)
cout << "Sjeciste je u tocki " << x1 << ',' << y1 << endl;
else
cout << "Sjecista su u tockama " << x1 << ',' << y1 << " i " << x2 << ',' << y2 << endl;}
system("PAUSE");
return 0;}
Bookmarks