Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 100/100 1,461 MiB 0,005 s OK

Ocenjevani program (Presek.cpp):
#include <stdio.h>

int main()
{
    int t, x1, y1, x2, y2, xk, yk, r;
    scanf("%d",&t);

    for(int z = 0; z < t; z++)
    {
        scanf("%d %d %d %d %d %d %d",&x1,&y1,&x2,&y2,&xk,&yk,&r);

        double distance = 0;

        if(xk <= x1 && yk >= y2)
        {
            distance = (xk - x1) * (xk - x1) + (yk - y2) * (yk - y2); 

            if(distance <= r * r)
                printf("%d %d\n",x1,y2);
            else
                printf("Presek je prazen\n");
        }
        else if(xk <= x1 && yk <= y1)
        {
            distance = (xk - x1) * (xk - x1) + (yk - y1) * (yk - y1);

            if(distance <= r * r)
                printf("%d %d\n",x1,y1);
            else
                printf("Presek je prazen\n");
        }
        else if(xk >= x2 && yk <= y1)
        {
            distance = (xk - x2) * (xk - x2) + (yk - y1) * (yk - y1);

            if(distance <= r * r)
                printf("%d %d\n",x2,y1);
            else
                printf("Presek je prazen\n"); 
        }
        else if(xk >= x2 && yk >= y2)
        { 
            distance = (xk - x2) * (xk - x2) + (yk - y2) * (yk - y2);

            if(distance <= r * r)
                printf("%d %d\n",x2,y2);
            else
                printf("Presek je prazen\n");
        }
        else if(xk >= x2 && yk < y2 && yk > y1)
        {
            if(xk - x2 <= r)
                printf("%d %d\n",x2,yk);
            else
                printf("Presek je prazen\n");
        }
        else if(xk <= x1 && yk < y2 && yk > y1)
        {
            if(x1 - xk <= r)
                printf("%d %d\n",x1,yk);
            else
                printf("Presek je prazen\n");
        }
        else if(yk >= y2 && xk < x2 && xk > x1)
        {
            if(yk - y2 <= r)
            {
                printf("%d %d\n",xk,y2);
            }
            else
                printf("Presek je prazen\n");
        }
        else if(yk <= y1 && xk < x2 && xk > x1)
        {
            if(y1 - yk < r)
            {
                printf("%d %d\n",xk,y1);
            }
            else
                printf("Presek je prazen\n");
        }
        else if(yk <= y2 && yk >= y1 && xk >= x1 && xk <= x2)
        {
            printf("%d %d\n",xk,yk);
        }
        else
        {
            printf("Presek je prazen\n");
        }
    }
}