2023-03-11 10:46:52 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2023-03-11 11:19:31 +00:00
|
|
|
#define LINE_SIZE 100
|
2023-03-11 10:46:52 +00:00
|
|
|
|
|
|
|
int main(){
|
|
|
|
|
|
|
|
float line[LINE_SIZE];
|
|
|
|
int count;
|
|
|
|
char buffer[50];
|
|
|
|
|
|
|
|
for(count = 0; count < LINE_SIZE; count++){
|
|
|
|
|
|
|
|
if(fgets(buffer, 50, stdin) == NULL || buffer[0] == '\n'){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int success = sscanf(buffer, "%f", &line[count]);
|
|
|
|
|
|
|
|
if(success == 0 || success == EOF){
|
|
|
|
if(count == 0){
|
|
|
|
printf("Nepodarilo sa nacitat x.\n");
|
|
|
|
}else{
|
2023-03-11 11:20:49 +00:00
|
|
|
printf("Nepodarilo sa nacitat polynom na %d mieste\n", count);
|
2023-03-11 10:46:52 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-11 11:09:51 +00:00
|
|
|
float result = 0;
|
2023-03-11 10:46:52 +00:00
|
|
|
float x = line[0];
|
|
|
|
|
|
|
|
for(int i = 1; i < count; i++){
|
|
|
|
result = result * x + line[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Vysledok je: %.2f\n", result);
|
|
|
|
|
|
|
|
}
|