cv3
This commit is contained in:
parent
ee2275bf4a
commit
b12617e67a
82
cv3/program.c
Normal file
82
cv3/program.c
Normal file
@ -0,0 +1,82 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#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;
|
||||
}
|
BIN
cv3/program.exe
Normal file
BIN
cv3/program.exe
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user