30 lines
735 B
C
30 lines
735 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#define LENGTH 256
|
|
|
|
int main(){
|
|
char line[LENGTH];
|
|
int cfIdx, cf1 = 0;
|
|
double x, cf,result = 0;
|
|
fgets(line, 100, stdin);
|
|
x = strtod(line, NULL);
|
|
cf1 = x;
|
|
if(cf1 == 0 && line[0] != '\n'){
|
|
printf("Nepodarilo sa nacitat zaklad x\n");
|
|
return 1;
|
|
}
|
|
while(line[0] != '\n'){
|
|
cfIdx++;
|
|
result = result * x + cf;
|
|
fgets(line, 100, stdin);
|
|
cf = strtod(line,NULL);
|
|
cf1 = cf;
|
|
if(cf1 == 0 && line[0] != '\n'){
|
|
printf("\nNepodarilo sa nacitat polynom na %d mieste.\n", cfIdx);
|
|
return 1;
|
|
}
|
|
}
|
|
printf("Vysledok je: %.2f\n", result);
|
|
return 0;
|
|
} |