Изменил(а) на 'du3/program.c'

This commit is contained in:
Vladyslav Korzun 2023-03-06 17:07:57 +00:00
parent a0a40567d3
commit ba3e148434

View File

@ -5,71 +5,73 @@
#include <math.h> #include <math.h>
#include <ctype.h> #include <ctype.h>
#define LINE_SIZE 150 #define LINE_SIZE 150
int main(){
char riadok[LINE_SIZE];
memset(riadok, 0,LINE_SIZE);
char* r;
float r2;
int stop = 0;
float mass[LINE_SIZE];
int i = 0;
float x = 0;
float vysl = 0;
int counter = -1;
float h = 0;
int pos = -1;
//float p = 0;
while(stop == 0){
r = fgets(riadok,LINE_SIZE,stdin);
if(feof(stdin)){
break;
}
pos++;
if (r == NULL || !isdigit(*r) || *r == EOF || feof(stdin)) { int main(){
//printf("%d", *r); char riadok[LINE_SIZE];
if(*r == 10){ memset(riadok, 0,LINE_SIZE);
stop = 1; char* r;
} float r2;
else{ int stop = 0;
if(pos > 0){ float mass[LINE_SIZE];
printf("Nepodarilo sa nacitat polynom na %d mieste.\n", pos); int i = 0;
return 0; float x = 0;
} float vysl = 0;
else{ int counter = -1;
printf("Nepodarilo sa nacitat zaklad x\n"); float h = 0;
return 0; int pos = -1;
} //float p = 0;
} while(stop == 0){
} r = fgets(riadok,LINE_SIZE,stdin);
r2 = atof(riadok); pos++;
mass[i] = r2; if (r == NULL || !isdigit(*r) || *r == EOF) {
//printf("%.2f\n", r2); //printf("%d", *r);
i++; if(*r == 10 || r == NULL){
//printf("%d\n", i); stop = 1;
} }
x = mass[0]; else{
vysl = x; if(pos > 0){
//printf("%d\n", x); printf("Nepodarilo sa nacitat polynom na %d mieste.\n", pos);
if(i != 3){ return 0;
for(int j = 1; j < i - 1; j++){ }
h = mass[j]; else{
//printf("h>>> %1.f\n", h); printf("Nepodarilo sa nacitat zaklad x\n");
if(counter == -1){ return 0;
vysl = x * h + mass[j + 1]; }
//printf("vysl>>> %1.f\n", vysl); }
counter++; }
} else if (*r == EOF) {
else{ stop = 1;
if(j != i - 2){ }
vysl = x * vysl + mass[j + 1]; else {
//printf("vysl22>>>>> %1.f\n", vysl); r2 = atof(riadok);
} mass[i] = r2;
} //printf("%.2f\n", r2);
} i++;
} //printf("%d\n", i);
else{ }
vysl = mass[1]; }
} x = mass[0];
printf("Vysledok je: %.2f\n", vysl); vysl = x;
//printf("%d\n", x);
if(i != 3){
for(int j = 1; j < i - 1; j++){
h = mass[j];
//printf("h>>> %1.f\n", h);
if(counter == -1){
vysl = x * h + mass[j + 1];
//printf("vysl>>> %1.f\n", vysl);
counter++;
}
else{
if(j != i - 2){
vysl = x * vysl + mass[j + 1];
//printf("vysl22>>>>> %1.f\n", vysl);
}
}
}
}
else{
vysl = mass[1];
}
printf("Vysledok je: %.2f\n", vysl);
} }