Rezultati

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

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

Ocenjevani program (new-2.txt):
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

struct testniPrimer {
	int xS, yS, xZ, yZ, xK, yK, r;
};

int razd(int x1, int y1, int x2, int y2) {
	return (pow((x1 - x2), 2) + pow((y1 - y2), 2));
}


void resitev(testniPrimer TP) {
	for (int i = TP.yS; i <= TP.yZ; i++) {
		int razda = razd(TP.xS, i, TP.xK, TP.yK);
		if ((razda - pow(TP.r, 2))<=0) {
			cout << TP.xS << " " << i;
			return;
		}
	}
	for (int i = TP.xS; i <= TP.xZ; i++) {
		int razda = razd(i, TP.yZ, TP.xK, TP.yK);
		if ((razda - pow(TP.r, 2)) <= 0) {
			cout << i << " " << TP.yZ;
			return;
		}
	}
	for (int i = TP.yZ; i >= TP.yS; i--) {
		int razda = razd(TP.xZ, i, TP.xK, TP.yK);
		if ((razda - pow(TP.r, 2)) <= 0) {
			cout << TP.xZ << " " << i;
			return;
		}
	}
	for (int i = TP.xZ; i >= TP.xS; i--) {
		int razda = razd(i, TP.yS, TP.xK, TP.yK);
		if ((razda - pow(TP.r, 2)) <= 0) {
			cout << i << " " << TP.yS;
			return;
		}
	}
	if (TP.xK <= TP.xZ && TP.xK >= TP.xS && TP.yK <= TP.yZ && TP.yK >= TP.yS) {
		cout << TP.xK <<  " "  <<  TP.yK;
		return;
	}
	cout << "Presek je prazen";
	return;
}




int main()
{

	int T;
	cin >> T;
	testniPrimer TP[101];
	for (int i = 0; i < T; i++) {
		cin >> TP[i].xS >> TP[i].yS >> 
			TP[i].xZ >> TP[i].yZ >> 
			TP[i].xK >> TP[i].yK >> 
			TP[i].r;
	}

	for (int i = 0; i < T; i++) {
		resitev(TP[i]);
		cout << endl;
	}

	return 0;
}