https://check-in.uni-heidelberg.de/erfassung/6205.03.104/
Error:
-Wall:
-Weverything:
// Variante 1
// ebenfalls: unnötiger call by value
bool sort_by_angle(point a, point b)
{
if (a[0] * b[1] - a[1] * b[0] > 0) {
return true;
}
// Split up for readability
else if (a[0] * b[1] - a[1] * b[0] == 0 && std::abs(a[0]) > std::abs(b[0])) {
return true;
}
return false;
}
// Variante 2
bool sort_by_angle(const coordinate &a, const coordinate &b) {
return (a[0] * b[1] - a[1] * b[0] > 0) or
(a[0] * b[1] - a[1] * b[0] == 0 and
(std::abs(a[0]) > std::abs(b[0])));
}
for (unsigned long i = 2; i < points.size(); ++i) {
if (!is_right(points[i-2], points[i], points[i-1])) {
points.erase(points.begin() + i - 1);
i -= 2;
}
}
Sonst gerne auch gleich in der Übungsphase!
Wollt ihr meine Lösung?
Aufgabe 1:
Übungsblatt 05 im Moodlekurs
Christian Heusel c.heusel@stud.uni-heidelberg.de https://discord.mathphys.info