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

This commit is contained in:
Vladyslav Korzun 2023-03-02 09:58:09 +00:00
parent 8002600ba2
commit a92e324394

View File

@ -1,55 +1,94 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>
#define LINE_SIZE 10 #define LINE_SIZE 10
int main(){ int main(){
char riadok[LINE_SIZE];
memset(riadok, 0,LINE_SIZE); char riadok[LINE_SIZE];
char* r;
double r2; memset(riadok, 0,LINE_SIZE);
int stop = 0;
double mass[LINE_SIZE]; char* r;
int i = 0;
double x = 0; float r2;
double vysl = 0;
int counter = -1; int stop = 0;
double h = 0;
while(stop == 0){ float mass[LINE_SIZE];
r = fgets(riadok,LINE_SIZE,stdin);
assert(r!=NULL); int i = 0;
r2 = atof(riadok);
//printf("%2.f\n", r2); float x = 0;
mass[i] = r2;
//printf("%2.f\n", mass[i]); float vysl = 0;
//printf("%.2f\n", r2);
i++; int counter = -1;
if (r2 == 0){
float h = 0;
while(stop == 0){
r = fgets(riadok,LINE_SIZE,stdin);
assert(r!=NULL);
r2 = atof(riadok);
mass[i] = r2;
//printf("%.2f\n", r2);
i++;
if (r2 == 0){
//printf("Konverzia sa nepodarila alebo v reťazci sa nachádza nula.\n"); //printf("Konverzia sa nepodarila alebo v reťazci sa nachádza nula.\n");
stop++;
} stop++;
}
x = mass[0]; }
//printf("%2.f\n", x);
//printf("%d\n", x); }
for(int j = i - 2; j > 0; j--){
counter++; x = mass[0];
h = mass[j];
//printf("%d ", h); //printf("%d\n", x);
if(j != 0){
if(counter != 0){ for(int j = 1; j < i - 1; j++){
vysl += h * powf(x,counter);
} h = mass[j];
else{
vysl += h; //printf("h>>>%1.f\n", h);
}
} if(counter == -1){
}
if(vysl != 53157.94141){ vysl = x * h;
printf("Vysledok je: %.2f\n", roundf(vysl * 100) / 100);
} counter++;
else{
printf("Vysledok je: 53157.95\n"); //printf("prv>>%1.f\n", vysl);
}
}
if(j != i){
vysl = x * vysl + mass[j + 1];
//printf("%1.f\n", vysl);
}
}
printf("Vysledok je: %2.f\n", roundf(vysl * 100) / 100);
} }