From 5cd49a058a568514e4d7081b2b65fdde79e630b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=A9re=C5=A1?= Date: Tue, 29 Oct 2019 13:46:53 +0000 Subject: [PATCH] Aktualizovat "program.c --- program.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/program.c b/program.c index 42c5c76..a4c241c 100644 --- a/program.c +++ b/program.c @@ -19,9 +19,18 @@ int main() { int cislo2; while((fgets(druhe_cislo,100,stdin))){ + cislo2= strtof(strtok(druhe_cislo,"\n"),NULL); int buf_C_1 = cislo1; int buf_C_2 = cislo2; + + if (isalpha(*druhe_cislo)){ + printf("%s je neplatny zapis.\n",prve_cislo); + free(prve_cislo); + free(druhe_cislo); + return 0; + + } while (cislo1 != cislo2){ if (cislo1 > cislo2){ cislo1 -= cislo2; @@ -29,15 +38,8 @@ int main() { cislo2 -= cislo1; } } + printf("Nacitane %d\n",cislo2); - if (isalpha(*prve_cislo)){ - printf("%s je neplatny zapis.\n",prve_cislo); - free(prve_cislo); - free(druhe_cislo); - return 0; - - } - printf("Nacitane %d\n",cislo1); printf("Najvacsi spolocny delitel cisel %ld a %ld je %ld\n",buf_C_1,buf_C_2,cislo1); }