(suradnica prichadza na vstup v tvare [x, y])
Kód: Vybrať všetko
while (!feof(stdin)){
if ((scanf(" %c %lf %c %lf %c", &f, &cx, &g, &cy, &h))!=5 && f != '[' && g != ',' && h != ']'){
printf("Nespravny vstup\n");
free(polex);
free(poley);
polex = NULL;
poley = NULL;
return 1;
}
for (int i = 0; i < pocet; i++) {
u = polex[i] - cx;
v = poley[i] - cy;
vysledok = sqrt((u*u) + (v*v));
if (vysledok>max){
max = vysledok;
}
}
printf("Max: %g\n", max);
max = 0;
}
Kód: Vybrať všetko
Nepriatel:
{ [1, 10], [2,1] , [-10, 20] }
Ciel:
[10,10]
Max: 22.3607
[3, 4]
Max: 20.6155
Max: 20.6155