57 lines
1.2 KiB
C
57 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include <assert.h>
|
|
#include <stdbool.h>
|
|
#include <ctype.h>
|
|
#define LINE_SIZE 55
|
|
int main(){
|
|
int n;
|
|
n=0;
|
|
double x[LINE_SIZE];
|
|
while(10==10){
|
|
char riadok[LINE_SIZE];
|
|
memset(riadok, 0,LINE_SIZE);
|
|
char* r = fgets(riadok,LINE_SIZE,stdin);
|
|
bool x1=true;
|
|
|
|
|
|
if (r == NULL){
|
|
break;
|
|
}
|
|
if (x1=true){
|
|
x[n]=strtof(riadok);
|
|
}
|
|
if (riadok[0]=='\n'){
|
|
x1=false;
|
|
}
|
|
if (isalpha(riadok[0])){
|
|
if (n<1 && n>-1){
|
|
printf("Nepodarilo sa nacitat zaklad x\n" );
|
|
break;
|
|
}
|
|
printf("Nepodarilo sa nacitat polynom na %d mieste.\n", n);
|
|
break;
|
|
}
|
|
if (x1=true){
|
|
n=n+1;
|
|
}
|
|
}
|
|
if (n==2){
|
|
printf("Vysledok je: %.2f\n", x[1]);
|
|
return 0;
|
|
}
|
|
long int a;
|
|
a=x[0];
|
|
long int v;
|
|
v=x[1];
|
|
long int result=0;
|
|
int l=0;
|
|
while (l<n-2){
|
|
l++;
|
|
result = a*v+x[l+1];
|
|
v=result;
|
|
}
|
|
printf("Vysledok: %.2f\n", result);
|
|
return 0;
|
|
} |