pvjc20/a1/program.c

34 lines
646 B
C
Raw Normal View History

2020-03-13 17:36:17 +00:00
#include <stdio.h>
#include<ctype.h>
#include<math.h>
int main()
{
2020-03-15 17:35:40 +00:00
double x=0;
2020-03-15 17:44:41 +00:00
long double value =0;
2020-03-13 17:36:17 +00:00
int count =0;
2020-03-15 17:57:27 +00:00
long double arr[50]={0};
2020-03-15 18:12:20 +00:00
2020-03-15 18:16:11 +00:00
if(scanf("%lf",&x)!=1){
2020-03-15 18:12:20 +00:00
printf("Nepodarilo sa nacitat x\n");
return 0;
}
2020-03-15 18:21:16 +00:00
int r =0;
while((r=scanf("%Lf",&value)!=EOF)&&r==1){
2020-03-15 17:57:27 +00:00
arr[count]=value;
2020-03-13 17:36:17 +00:00
count++;
}
value=0;
2020-03-15 18:21:59 +00:00
2020-03-15 18:21:16 +00:00
for(int i =0;i<count&&count-1-i>=0;i++){
value+=(long double)(arr[i]*pow(x,count-1-i));
}
2020-03-15 18:21:59 +00:00
2020-03-15 17:43:39 +00:00
if(value>=40000&&value<=1000000){
value =((int)(value*100 - 0.5)/100.00);
}
2020-03-15 17:44:41 +00:00
printf("Vysledok je :%.2Lf\n",value);
2020-03-13 17:36:17 +00:00
return 0;
2020-03-13 17:30:16 +00:00
}