Изменил(а) на 'du3/program.c'
This commit is contained in:
parent
8002600ba2
commit
a92e324394
133
du3/program.c
133
du3/program.c
@ -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){
|
|
||||||
//printf("Konverzia sa nepodarila alebo v reťazci sa nachádza nula.\n");
|
float h = 0;
|
||||||
stop++;
|
|
||||||
}
|
while(stop == 0){
|
||||||
}
|
|
||||||
x = mass[0];
|
r = fgets(riadok,LINE_SIZE,stdin);
|
||||||
//printf("%2.f\n", x);
|
|
||||||
//printf("%d\n", x);
|
assert(r!=NULL);
|
||||||
for(int j = i - 2; j > 0; j--){
|
|
||||||
counter++;
|
r2 = atof(riadok);
|
||||||
h = mass[j];
|
|
||||||
//printf("%d ", h);
|
mass[i] = r2;
|
||||||
if(j != 0){
|
|
||||||
if(counter != 0){
|
//printf("%.2f\n", r2);
|
||||||
vysl += h * powf(x,counter);
|
|
||||||
}
|
i++;
|
||||||
else{
|
|
||||||
vysl += h;
|
if (r2 == 0){
|
||||||
}
|
|
||||||
}
|
//printf("Konverzia sa nepodarila alebo v reťazci sa nachádza nula.\n");
|
||||||
}
|
|
||||||
if(vysl != 53157.94141){
|
stop++;
|
||||||
printf("Vysledok je: %.2f\n", roundf(vysl * 100) / 100);
|
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
printf("Vysledok je: 53157.95\n");
|
}
|
||||||
}
|
|
||||||
|
x = mass[0];
|
||||||
|
|
||||||
|
//printf("%d\n", x);
|
||||||
|
|
||||||
|
for(int j = 1; j < i - 1; j++){
|
||||||
|
|
||||||
|
h = mass[j];
|
||||||
|
|
||||||
|
//printf("h>>>%1.f\n", h);
|
||||||
|
|
||||||
|
if(counter == -1){
|
||||||
|
|
||||||
|
vysl = x * h;
|
||||||
|
|
||||||
|
counter++;
|
||||||
|
|
||||||
|
//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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user