From a6f3632b7f8a2276200eec68f249e6c6a75729fd Mon Sep 17 00:00:00 2001 From: Manuel Bucher <manuel.bucher@hu-berlin.de> Date: Mon, 18 Jun 2018 14:50:21 +0200 Subject: [PATCH] fixed Rechteckausgabe --- loesung.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/loesung.c b/loesung.c index 822580b..4b678ab 100644 --- a/loesung.c +++ b/loesung.c @@ -124,21 +124,21 @@ bool list_rectangle(List *this) { * Voraussetzung: notwendiges Kriterium erfuellt & es handelt sich um ein Rechteck */ void list_print_rectangle(List *this) { - for (uint32_t y = this->min.y;; y++) { - for (uint32_t x = this->min.x;; x+=2) { - if (x == this->max.x - 1) { - if ((y - this->min.y) % 2 == 0) { + for (uint32_t x = this->min.x;; x++) { + for (uint32_t y = this->min.y;; y+=2) { + if (y == this->max.y) { + if ((x - this->min.x) % 2 == 0) { // vertikaler Stein - printf("%u %u;%u %u\n", x, y, x, y+1); + printf("%u %u;%u %u\n", x, y, x+1, y); } break; } - printf("%u %u;%u %u\n", x, y, x+1, y); - if (x == this->max.x) { - break; + printf("%u %u;%u %u\n", x, y, x, y+1); + if (y == this->max.y-1) { + break; // ende des Zeile erreicht } } - if(y == this->max.y) { + if(x == this->max.x) { break; } } -- GitLab