diff --git a/cv2/program.c b/cv2/program.c index e02f525..cdc89c4 100644 --- a/cv2/program.c +++ b/cv2/program.c @@ -20,10 +20,7 @@ int main() { 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') { @@ -37,6 +34,9 @@ int main() { } else if (i == 1){ cena = atof(line); + if (cena == 0.0){ + break; + } jedalny_listok[a].prize = cena; i--; @@ -49,8 +49,8 @@ int main() { // a = a / 2; //printf("%d", a); - for (c = 0; c < a-1; c++){ - for (d = 0; d < a - c-1; d++){ + for (c = 0; c < a - 1; c++){ + for (d = 0; d < a - c - 1; d++){ if(jedalny_listok[d].prize == jedalny_listok[d+1].prize){ if(strcmp(jedalny_listok[d].name, jedalny_listok[d+1].name) > 0){ struct Pizza tmp;