E
Edip
C++:
#include <iostream>
#include <conio.h>
#include <time.h>
using namespace std;
template <typename T> void root (T, T);
template <typename T> void root (T, T, T);
void main()
{
root(1,2);
root(2.,5.,2.);
cin.get();
}
template <typename T> void root (T a, T b)
{
if ((a==0) && (b==0))
{
cout<<"Net resheniy\n";
}
else
{
if ((b!=0) && (a==0))
{
cout<<"x=0\n";
}
else
{
cout<<"x="<<(-b/(2*a))<<"\n";
}
}
}
template <typename T> void root (T a, T b, T c)
{
double x1,x2;
double D=b*b-4*a*c;
if (D<0)
{
cout<<"Korney net!\n";
}
else
{
if (D==0)
{
cout<<"x="<<(-b/(2*a))<<"\n";
}
else
{
x1=-((b+pow(D,0.5))/(2*a));
x2=-((b-pow(D,0.5))/(2*a));
if (((x1+x2)==(-(b/a)))&&((x1*x2)==(c/a)))
{
cout<<"x1="<<x1<<"\n";
cout<<"x2="<<x2<<"\n";
}
else
{
cout<<":((\n";
}
}
}
}