From 345841f3028a260c92d3a4b761100b7e74c4f493 Mon Sep 17 00:00:00 2001 From: Bohdana Marchenko Date: Wed, 26 Mar 2025 23:38:06 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20du2/program.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du2/program.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/du2/program.c b/du2/program.c index 3a7fbb5..59ee5ec 100644 --- a/du2/program.c +++ b/du2/program.c @@ -3,10 +3,10 @@ #include #include -#define LINE_SIZE 100 +#define LINE_SIZE 100 //maximalna veľkosť čiary int read_double(double *value, int coef_index) { - char line[LINE_SIZE]; + char line[LINE_SIZE]; //deklaruje pole na uloženie reťazca if (fgets(line, LINE_SIZE, stdin) == NULL) { return 0; @@ -20,8 +20,8 @@ int read_double(double *value, int coef_index) { return 0; } - char *endptr; - *value = strtod(line, &endptr); + char *endptr; // smernik na hľadanie konca reťazca pri prevode na číslo + *value = strtod(line, &endptr); // Prevod reťazca na dvojité číslo if (endptr == line || *endptr != '\0') { @@ -39,13 +39,13 @@ int main() { return 1; } - double coef; - double result = 0; - int coef_count = 0; + double coef; //uloženie koeficientu polynómu + double result = 0; // uloženie výsledku + int coef_count = 0; //Počítadlo počtu zadaných koeficientov - while (1) { + while (1) { //Nekonečný cyklus na zadávanie koeficientov coef_count++; - int status = read_double(&coef, coef_count); + int status = read_double(&coef, coef_count); //Číta koeficient if (status == -1) { return 0;