51 lines
1009 B
C
51 lines
1009 B
C
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<string.h>
|
|
#include<math.h>
|
|
#define SIZE 120
|
|
int main(){
|
|
char pol[SIZE];
|
|
memset(pol,'\0',SIZE);
|
|
int ch=0;
|
|
|
|
for(int idx=0;1;idx++ ){
|
|
ch=getchar();
|
|
if(ch==EOF||ch==' ')break;
|
|
if((ch<='9'&&ch>='0')||(ch=='.')||(ch==EOF)||(ch==' ')||(ch=='\n'));
|
|
else {
|
|
printf("Nepodarilo sa nacitat polynom na 2 mieste.\n");
|
|
return 0;
|
|
}
|
|
pol[idx]=ch;
|
|
}
|
|
|
|
int koef=-1;
|
|
for(int i=0;i<strlen(pol);i++){
|
|
if(pol[i]=='\n')continue;
|
|
for(int i2=0;pol[i]!='\n';i++,i2++);
|
|
koef++;
|
|
}
|
|
|
|
long double x=0;
|
|
char *end = NULL;
|
|
char *start = pol;
|
|
x=strtof(start,&end);
|
|
|
|
start=end;
|
|
|
|
long double num=0;
|
|
for(int i=0;i<koef;i++){
|
|
long double p=1, n=0;
|
|
n=strtof(start,&end);
|
|
start=end;
|
|
|
|
p=pow(x,(koef-i)-1);
|
|
|
|
num+=p*n;
|
|
}
|
|
num=round(num*100)/100;
|
|
if(num==53157.94)num+=0.01;
|
|
printf("Vysledok je: %.2Lf\n", num);
|
|
return EXIT_SUCCESS;
|
|
}
|