From ab1ac589a85f3d7bbdfd80b8fd10cb20c347c752 Mon Sep 17 00:00:00 2001 From: ak643du Date: Mon, 4 Mar 2024 19:57:08 +0100 Subject: [PATCH] Initialization --- cv3/program.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index b48d5b4..0dc6c66 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -11,11 +11,18 @@ int main() { int length = 0; double result = 0.0; - while (count < SIZE) { - if (scanf("%d", &input) != 1) { - printf("Nepodarilo sa nacitat polynom na %d mieste.", count); - break; + while (count < SIZE) + { + if (input == '\n') + { + continue; + } + + if (scanf("%d", &input) != 1) + { + printf("Nepodarilo sa nacitat polynom na %d mieste.", count); + return 0; } coefs[count] = input; count++; @@ -25,8 +32,9 @@ int main() { length = count; - for (int i = 1; i < length; i ++){ - result = result * x + coefs[i]; + for (int i = 1; i < length; i ++) + { + result = result * x + coefs[i]; } printf("Vysledok je: %.2lf\n", result);