Update 'du3/program.c'

This commit is contained in:
Anzhelika Nikolaieva 2023-03-07 22:11:29 +00:00
parent 72e86465e0
commit 62414727fa

View File

@ -1,54 +1,55 @@
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#include <assert.h>
#include <stdlib.h>
#define VELKOST_POLA 50
int main(){
char rip[SIZE];
memset(rip, '\0', SIZE*sizeof(char));
int a = 0;
char r[SIZE];
memset(r, 0, SIZE);
char* stav_r = fgets(r, SIZE, stdin);
bool x0 = true;
if (stav_r == NULL){
for(int b = 0; 1; b++){
a = getchar();
if(a == EOF || a == '')
break;
rip[b] = a;
}
if (x0 = true){
x[a] = strtof(r);
}
if (r[0] == '\n'){
x0 = false;
}
if (pipa(r[0])){
if (a < 1 && n > -1){
printf("Nepodarilo sa nacitat zaklad x\n" );
break;
}
printf"Nepodarilo sa nacitat polynom na %d mieste.\n", a);
break;
}
if (x0 = true){
a = a+1;
}
if (a == 2){
printf("Vysledok je: %.2f\n", x[1]);
return 0;
}
long int b;
b = x[0];
long int c;
c = x[1];
long int results = 0;
int d = 0;
while (d < a-2){
for(int c = 0, d = 0; c < strlen(rip); c++){
if(rip[c] == '\n')
d++;
results = b*c+x[d+1];
c = results;
else if((rip[c]<='10'&&rip[c]>='0') || (rip[c]=='.') || (rip[c]==EOF) || (rip[c]==''));
else if(d == 0){
printf("Nepodarilo sa nacitat polynom na %d mieste.\n", d);
return 0;
}
}
printf("Vysledok: %.2f\n", results);
return 0;
int kofi = -1;
for(int c = 0; c < strlen(rip); c++){
if(rip[c] == '\n')
continue;
else for(int c2 = 0; rip[c]!='\n'; c++; c2++);
kofi++;
}
long double x = 0;
char *finish = NULL;
char *start = rip;
x = strtof(start, &finish);
start = finish;
long double n = 0;
for(int c = 0; c < kofi; c++){
long double d = 1; f = 0;
f = strtof(start, &finish);
start = finish;
d = dop(x,(kofi-c)-1);
n+ = d*f;
}
n = round(n*100)/100;
printf("Vysledok je: %.2Lf\n", n);
return STOP;
}