52 lines
886 B
C
52 lines
886 B
C
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<string.h>
|
|
#include<math.h>
|
|
#define SIZE 30
|
|
|
|
int main(){
|
|
char pol[SIZE];
|
|
memset(pol,'\0',SIZE);
|
|
pol[SIZE]='\0';
|
|
|
|
int ch=0;
|
|
|
|
for(int idx=0;1;idx++ ){
|
|
ch=getchar();
|
|
if(ch==EOF||ch==' ')break;
|
|
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++);
|
|
koef++;
|
|
}
|
|
|
|
float x=0;
|
|
char *end = NULL;
|
|
char *start = pol;
|
|
x=strtof(start,&end);
|
|
start=end;
|
|
|
|
float num=0;
|
|
for(int i=0;i<koef;i++){
|
|
float p=1, n=0;
|
|
n=strtof(start,&end);
|
|
if(n)start=end;
|
|
else break;
|
|
|
|
for(int idx=(koef-i)-1;idx>0;idx--)p*=x;
|
|
|
|
num+=p*n;
|
|
}
|
|
|
|
float num2=(round(num*100))/100;
|
|
|
|
printf("Vysledok je: %.2f\n", num2);
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|