46 lines
730 B
C
46 lines
730 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
#define LINE_SIZE 256
|
|
|
|
int main() {
|
|
char line[LINE_SIZE];
|
|
|
|
int counter = 0;
|
|
|
|
double x, kef, resultat = 0.0;
|
|
|
|
|
|
if(fgets(line, sizeof(line), stdin) == NULL) {
|
|
|
|
return 1;
|
|
}
|
|
|
|
if (sscanf(line, "%lf", &x) != 1) {
|
|
|
|
printf("Invalid input for x.\n");
|
|
return 1;
|
|
|
|
}
|
|
while (fgets(line, sizeof(line), stdin) != NULL)
|
|
|
|
{
|
|
if (line[0] == '\n' || line[0] == '\r') {
|
|
|
|
break;
|
|
|
|
}
|
|
if (sscanf(line, "%lf", &kef) == 1) {
|
|
resultat = resultat * x + kef;
|
|
counter = counter + 1;
|
|
|
|
}
|
|
else {
|
|
printf("Invalid input for coefficient.\n");
|
|
return 1;
|
|
}
|
|
}
|
|
printf("Vysledok je: %.2f\n", resultat);
|
|
return 0;
|
|
} |