test
This commit is contained in:
parent
304ee55695
commit
00786a8829
10
a1/program.c
10
a1/program.c
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h> // Include string.h for strlen
|
||||||
|
|
||||||
#define MAX_LINE_LENGTH 100
|
#define MAX_LINE_LENGTH 100
|
||||||
|
|
||||||
@ -9,7 +10,6 @@ int main() {
|
|||||||
char uloha[MAX_LINE_LENGTH];
|
char uloha[MAX_LINE_LENGTH];
|
||||||
|
|
||||||
while (fgets(uloha, MAX_LINE_LENGTH, stdin) != NULL) {
|
while (fgets(uloha, MAX_LINE_LENGTH, stdin) != NULL) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
int isEmpty = 1;
|
int isEmpty = 1;
|
||||||
for (i = 0; uloha[i] != '\0'; i++) {
|
for (i = 0; uloha[i] != '\0'; i++) {
|
||||||
@ -23,11 +23,11 @@ int main() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cislo1, cislo2;
|
double cislo1, cislo2;
|
||||||
double vysledok_zadany;
|
double vysledok_zadany;
|
||||||
char operacia;
|
char operacia;
|
||||||
|
|
||||||
if (sscanf(uloha, "%d %c %d = %lf", &cislo1, &operacia, &cislo2, &vysledok_zadany) != 4) {
|
if (sscanf(uloha, "%lf %c %lf = %lf", &cislo1, &operacia, &cislo2, &vysledok_zadany) != 4) {
|
||||||
printf("CHYBA\n");
|
printf("CHYBA\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ int main() {
|
|||||||
printf("ZLE\n");
|
printf("ZLE\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
vysledok_skutocny = (double) cislo1 / cislo2;
|
vysledok_skutocny = cislo1 / cislo2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("CHYBA\n");
|
printf("CHYBA\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user