Rezultati

Up. imeNalogaJezikRezultatČas oddaje
vlakectomaz-2018 Presek C++ 100/100OK 04. okt '18 @ 18:12

Test Točke Porabljen spomin Porabljen čas Status
#1 100/100 3,133 MiB 0,000 s OK

Ocenjevani program (presek.cpp):
#include <iostream>
using namespace std;

double znotrajKvadrata(double x1, double y1, double x2, double y2, double xk, double yk){
    if(x1<=xk and xk<=x2 and y1<=yk and yk<=y2)
        return 1;
    return 0;
}

double znotrajKroga(double x, double y, double xk, double yk, double r){
    if(((x-xk)*(x-xk)+(y-yk)*(y-yk))<=r*r)
        return 1;
    return 0;
}



int main(){
    double x1,y1,x2,y2,xk,yk,r;
    int t;
    cin>>t;
    for (int i=0;i!=t;++i){
        cin>>x1>>y1>>x2>>y2>>xk>>yk>>r;
        if(znotrajKvadrata(x1,y1,x2,y2,xk,yk)){
            cout<<xk<<" "<<yk<<endl;
            continue;
        }
        if(znotrajKroga(x1, y1, xk, yk, r)){
            cout<<x1<<" "<<y1<<endl;
            continue;
        }

        if(znotrajKroga(x2, y2, xk, yk, r)){
            cout<<x2<<" "<<y2<<endl;
            continue;
        }
        if(znotrajKroga(x2, y1, xk, yk, r)){
            cout<<x2<<" "<<y1<<endl;
            continue;
        }
        if(znotrajKroga(x1, y2, xk, yk, r)){
            cout<<x1<<" "<<y2<<endl;
            continue;
        }
        if(znotrajKvadrata(x1,y1,x2,y2,xk+r,yk)){
            cout<<xk+r<<" "<<yk<<endl;
            continue;
        }
        if(znotrajKvadrata(x1,y1,x2,y2,xk-r,yk)){
            cout<<xk-r<<" "<<yk<<endl;
            continue;
        }
        if(znotrajKvadrata(x1,y1,x2,y2,xk,yk+r)){
            cout<<xk<<" "<<yk+r<<endl;
            continue;
        }
        if(znotrajKvadrata(x1,y1,x2,y2,xk,yk-r)){
            cout<<xk<<" "<<yk-r<<endl;
            continue;
        }
        if(x1<=xk and xk<=x2 and  y2<=yk+r and y1>=yk-r){
           cout << xk << " " << y2<<endl;
           continue;
        }
        if(y1<=yk and yk<=y2 and  x2<=xk+r and x1>=xk-r){
           cout << x2 << " " << yk<<endl;
           continue;
        }
        
        
        cout<<"Presek je prazen"<<endl;
        
    }
}