36 lines
811 B
C
36 lines
811 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
|
|
int main () {
|
|
char* input = (char*) calloc (100, sizeof(char));
|
|
double x;
|
|
char* ptr;
|
|
int counter = 0;
|
|
double numbers [100];
|
|
numbers[0] = 0;
|
|
for (int i = 0; fgets(input, 100, stdin) != NULL; i++){
|
|
if (!strcmp("\n", input))
|
|
break;
|
|
|
|
if (i == 0){
|
|
x = (double)strtod(input, &ptr, 10);
|
|
}
|
|
else {
|
|
numbers [i] = (double)strtod(input, &ptr, 10);
|
|
}
|
|
counter = i;
|
|
}
|
|
double result = 0;
|
|
for(int i = 1; i <= counter; i++)
|
|
result += pow (x, i-1) * numbers [counter - i + 1];
|
|
|
|
result = roundf((float) result * 100)/100;
|
|
|
|
printf ("Vysledok je: ");
|
|
printf ("%.2f\n", result);
|
|
free(input);
|
|
return 0;
|
|
}
|