From b6dc89f520ca22fbb7dae4b0742f91de50355f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Korpesio?= Date: Wed, 13 Oct 2021 13:22:54 +0200 Subject: [PATCH] prvy --- cv2/program.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cv2/program.c b/cv2/program.c index e13a9ae..5da48b6 100644 --- a/cv2/program.c +++ b/cv2/program.c @@ -18,7 +18,12 @@ int main() { size_t velkost; int a = 0; int i = 0; + int c; + int d; + float pred; float cena; + char strpred[LINESIZE]; + memset(strpred,0,LINESIZE); while (fgets(line, LINESIZE, stdin)) { velkost = strlen(line); if (velkost == 1 && line[velkost - 1] == '\n') { @@ -38,7 +43,28 @@ int main() { a++; } } + + a = a / 2; + + for (c = 0; c < a - 1; c++){ + for (d = 0; d < a - c - 1; d++){ + d++; + if (jedalny_listok[d].prize > jedalny_listok[d+2].prize){ + pred = jedalny_listok[d].prize; + jedalny_listok[d].prize = jedalny_listok[d + 2].prize; + jedalny_listok[d+2].prize = pred; + strpred[d] = jedalny_listok[d - 1].name; + jedalny_listok[d - 1].name = jedalny_listok[d + 1]; + jedalny_listok[d + 1].name = strpred[d]; + + } + } + } + + + a = a * 2; for (i = 0; i