Cod sursa(job #2077523)

Utilizator Claudiu07Pana Claudiu Claudiu07 Data 28 noiembrie 2017 10:35:44
Problema Laser Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.79 kb
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
using namespace std;
ifstream f("laser.in");
ofstream g("laser.out");
int n;
bool ok[514];
struct neon
{
    float val1,val2;
}v[514];
double grade(double radians) {
     double degrees = radians / (2 * M_PI) * 360;
     if (degrees < 0)
         degrees += 360;
     return degrees;
}
void read()
{
    f>>n;
    int x1,x2,y1,y2;
    for(int i=1; i<=n; i++)
        {f>>x1>>y1>>x2>>y2;
          v[i].val1=grade(atan2(float(y1),x1));
          v[i].val2=grade(atan2(float(y2),x2));
        }
    for(int i=1; i<=n; i++)
        f>>ok[i];
}
bool cmp(neon a, neon b)
{
    if(a.val1>=b.val1) return 0;
    return 1;
}
int main()
{
    read();
    sort(v+1, v+n+1, cmp);
    return 0;
}