From 21c2ce23d007c7a9f3e515ff017dac78f3231623 Mon Sep 17 00:00:00 2001 From: ak643du Date: Mon, 4 Mar 2024 14:14:10 +0100 Subject: [PATCH] Initialization --- cv3/program.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cv3/program.c b/cv3/program.c index ac5d39f..6a5998f 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -3,21 +3,31 @@ #define SIZE 10 int main() { - char coefs[SIZE]; + int coefs[SIZE]; int x = 0; int input; int count = 0; + int length; + int result = 0; while (count < SIZE && scanf("%d", &input) == 1) { coefs[count] = input; count++; } + length = count; + + for (int i = length - 1; i >= 0; i--) { + result += coefs[0] * coefs[i]; + } + printf("Coefficients: "); for (int i = 0; i < count; i++) { printf("%d ", coefs[i]); } + printf("\nResult: %d\n", result); return 0; } +