prvy pokus

This commit is contained in:
Aleš Novysedlák 2025-03-03 18:13:28 +01:00
parent 09539b1cba
commit 8c8ec36eca

View File

@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main() {
float x;
float coeficient[100];
int counter = 0;
char buffer[50];
fgets(buffer, sizeof(buffer), stdin);
sscanf(buffer, "%f", &x);
while (fgets(buffer, sizeof(buffer), stdin) != NULL) {
if (sscanf(buffer, "%f", &coeficient[counter]) != 1) break;
counter++;
}
float result = 0.0;
for (int i = 0; i < counter; i++) {
result = result * x + coeficient[i];
}
printf("Vysledok je: %.2f\n", round(result * 100) / 100);
return 0;
}