Cod sursa(job #3220085)

Utilizator MagicantPlusIuoras Andrei MagicantPlus Data 2 aprilie 2024 12:10:29
Problema Algoritmul lui Dijkstra Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.57 kb
#include <fstream>
#include <algorithm>
#include <cmath>

using namespace std;

ifstream fin("data.in");
ofstream fout("data.out");

const double margin = 0.000001;

class Real
{
public:
    double val;
    operator double();
    template<class T> operator T();
    template<class T> void operator=(T val);
    template<class T> bool operator==(T val);
    template<class T> bool operator>(T val);
    template<class T> bool operator>=(T val);
    template<class T> bool operator<(T val);
    template<class T> bool operator<=(T val);
};

int cmpD(double x, double y);

int main()
{
    Real x[3], y[3];

    fin >> x[0].val >> y[0].val >> x[1].val >> y[1].val >> x[2].val >> y[2].val;

    fout << x[0];

    return 0;
}

int cmpD(double x, double y)
{
    if(abs(x-y) < margin) return 0;
    if(x-y < margin) return -1;
    return 1;
}
Real::operator double()
{
    return this->val;
}
template<class T> Real::operator T()
{
    return static_cast<T>(this->val);
}
template<class T> void Real::operator=(T val)
{
    this->val = static_cast<double>(val);
}
template<class T> bool Real::operator==(T val)
{
    return cmpD(this->val, static_cast<double>(val)) == 0;
}
template<class T> bool Real::operator>(T val)
{
    return cmpD(this->val, static_cast<double>(val)) > 0;
}
template<class T> bool Real::operator>=(T val)
{
    return cmpD(this->val, static_cast<double>(val)) >= 0;
}
template<class T> bool Real::operator<(T val)
{
    return cmpD(this->val, static_cast<double>(val)) < 0;
}
template<class T> bool Real::operator<=(T val)
{
    return cmpD(this->val, static_cast<double>(val)) <= 0;
}