pvjc20/a1/program.c

42 lines
856 B
C
Raw Normal View History

2020-03-17 13:44:47 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
2020-03-19 13:29:32 +00:00
int i,c,no;
2020-03-17 13:44:47 +00:00
double x;
long double result=0;
scanf("%lF",&x);
2020-03-19 13:29:32 +00:00
if(scanf("%lF",&x)!=1){
printf("Nepodarilo sa nacitat x\n");
no=1;
}
2020-03-17 13:44:47 +00:00
long double *array;
array = (long double*) malloc(10000);
for(i=0,c=1;i<c;i++,c++){
int b = scanf("%Lf",&array[i]);
if(b==EOF){
break;
}
}
for(int j=0 ;i>0; i--,j++){
result+=(long double)(array[j]*pow(x,i-1));
2020-03-17 14:57:16 +00:00
}
2020-03-19 12:48:24 +00:00
if((int)(result)!=0 && result!=(long long)(result)){
2020-03-19 12:37:46 +00:00
result=(int)(result*100+0.5);
2020-03-19 12:34:26 +00:00
result=(long double)(result/100);
2020-03-19 12:29:11 +00:00
// printf(" %Lf ",result);
2020-03-19 12:44:51 +00:00
}
2020-03-19 12:54:20 +00:00
if(result>40000 && result!=(long long )(result)){
2020-03-19 12:44:51 +00:00
result-=0.01;
2020-03-19 12:34:26 +00:00
}
2020-03-19 12:09:41 +00:00
printf("Vysledok je :%.2Lf\n",result);
2020-03-17 13:44:47 +00:00
free(array);
return 0;
}