pvjc24/cv3/program.c

32 lines
440 B
C
Raw Normal View History

2024-02-29 13:23:40 +00:00
#include <stdio.h>
#define SIZE 10
int main() {
2024-03-04 13:14:10 +00:00
int coefs[SIZE];
2024-02-29 13:23:40 +00:00
int x = 0;
2024-03-04 12:55:19 +00:00
int input;
2024-02-29 13:23:40 +00:00
int count = 0;
2024-03-04 13:14:10 +00:00
int length;
int result = 0;
2024-03-04 12:55:19 +00:00
2024-03-04 13:02:52 +00:00
while (count < SIZE && scanf("%d", &input) == 1) {
coefs[count] = input;
count++;
}
2024-03-04 12:55:19 +00:00
2024-03-04 13:35:38 +00:00
x = coefs[0];
2024-03-04 13:14:10 +00:00
length = count;
2024-03-04 13:29:52 +00:00
for (int i = 1; i < length; i ++){
2024-03-04 13:35:38 +00:00
result = result * x + coefs[i];
2024-03-04 13:14:10 +00:00
}
2024-03-04 13:29:52 +00:00
printf("Result: %d\n", result);
2024-02-29 13:23:40 +00:00
return 0;
}
2024-03-04 13:02:52 +00:00
2024-03-04 13:14:10 +00:00