diff --git a/cv3/program.c b/cv3/program.c new file mode 100644 index 0000000..464b448 --- /dev/null +++ b/cv3/program.c @@ -0,0 +1,82 @@ +#include +#include +#include +#include +#include + +#define POLE 100 + +int main() { + + double X = 0.00; + char vstup[POLE]; + memset(vstup, 0,POLE); //osetrenie + char* a = fgets(vstup,POLE,stdin); + + + if (vstup[0] == '\n'){ //ked pride na enter + printf("koniec"); + exit(0); + } + + + for (int i = 0; i < strlen(vstup)-1; i++){ + //X = atof(riadok); + if(vstup[i] == '.'){ + continue; + } + if (isdigit(vstup[i]) == 0){ + printf ("neplati\n"); + exit(0); + } + } + X = atof(a); + + + double polynom = 0.00; + char Ppole [POLE]; + memset(Ppole, 0,POLE); + double rovnica [POLE]; + int index = 0; + int stupen = 0; + double vysledok = 0.00; + int idx = 0; + + while (1){ + char* b = fgets(Ppole,POLE,stdin); + + if (Ppole[0] == '\n'){ //ked pride na enter + break; + } + for (int i = 0; i < strlen(Ppole)-1; i++){ + //X = atof(riadok); + if(Ppole[i] == '.'){ + continue; + } + if (isdigit(Ppole[i]) == 0){ + printf ("neplati\n"); + exit(0); + } + } + + polynom = atof (b); + rovnica[index] = polynom; + index++; + stupen++; + +} + +for (int i = stupen -1; i >= 0; i --){ + vysledok = vysledok + rovnica[idx] * pow(X, i); + idx++; + } + + + vysledok = round (vysledok * 100)/100; + printf ("vysledok je: %.2f \n", vysledok); + + + + + return 0; +} \ No newline at end of file diff --git a/cv3/program.exe b/cv3/program.exe new file mode 100644 index 0000000..7f2e7d3 Binary files /dev/null and b/cv3/program.exe differ