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

This commit is contained in:
Vladyslav Korzun 2023-03-08 14:46:24 +00:00
parent 1efeb02510
commit 444ee72756

View File

@ -18,10 +18,11 @@ int main() {
float cislo = 0.0; float cislo = 0.0;
float a = 0; float a = 0;
float b = 0; float b = 0;
float c = 0; float c = 1;
int counter = 0; int counter = 0;
float sr= 0; float sr= 0;
int p = 0; int p = 0;
int check = 0;
while ((r = fgets(znaky, LINE_SIZE, stdin)) != NULL) { while ((r = fgets(znaky, LINE_SIZE, stdin)) != NULL) {
if(znaky[0] == '\n'){ if(znaky[0] == '\n'){
break; break;
@ -42,24 +43,27 @@ int main() {
} }
zaciatok_cisla = znaky; zaciatok_cisla = znaky;
while (*zaciatok_cisla != '\0') { while (*zaciatok_cisla != '\0') {
cislo = strtof(zaciatok_cisla, &koniec_cisla); cislo = strtof(zaciatok_cisla, &koniec_cisla);
if (zaciatok_cisla == koniec_cisla) { if (zaciatok_cisla == koniec_cisla) {
zaciatok_cisla++; printf("CHYBA\n");
} else { check = 1;
if(counter == 0){ break;
a = cislo; }
} else {
if(counter == 1){ if(counter == 0){
b = cislo; a = cislo;
} }
if(counter == 2){ if(counter == 1){
c = cislo; b = cislo;
} }
counter++; if(counter == 2){
//printf("Nasiel som cislo %f\n", cislo); c = cislo;
zaciatok_cisla = koniec_cisla + 1; }
} counter++;
} //printf("Nasiel som cislo %f\n", cislo);
zaciatok_cisla = koniec_cisla + 1;
}
}
counter = 0; counter = 0;
for(int j = 0; j < sym; j++){ for(int j = 0; j < sym; j++){
if(symbol[j] == '=') if(symbol[j] == '=')
@ -92,12 +96,15 @@ int main() {
} }
} }
sr = roundf(sr * 100) / 100; sr = roundf(sr * 100) / 100;
if(check != 1){
if(c == sr){ if(c == sr){
printf("OK\n"); printf("OK\n");
} }
else{ else{
printf("ZLE\n"); printf("ZLE\n");
} }
}
check = 0;
sym = 0; sym = 0;
} }
if (feof(stdin)) { if (feof(stdin)) {