This commit is contained in:
Damián Korpesio 2021-10-20 10:53:38 +02:00
parent 6eb525c34d
commit 7ae3daf85e

View File

@ -17,7 +17,7 @@ int main() {
int i; int i;
int input = 0; int input = 0;
float p; float p;
//float prvy, druhy, vys; float vys;
while (fgets(line, LINESIZE, stdin)) { while (fgets(line, LINESIZE, stdin)) {
velkost = strlen(line); velkost = strlen(line);
if (velkost == 1 && line[velkost - 1] == '\n') { if (velkost == 1 && line[velkost - 1] == '\n') {
@ -45,6 +45,8 @@ int main() {
if (line[0] == '/') { if (line[0] == '/') {
if (number[a - 1].cislo == 0){ if (number[a - 1].cislo == 0){
printf("division by zero"); printf("division by zero");
vys = 1;
a = 0;
} }
else { else {
number[a - 2].cislo = number[a - 2].cislo / number[a - 1].cislo; number[a - 2].cislo = number[a - 2].cislo / number[a - 1].cislo;
@ -62,9 +64,9 @@ int main() {
for (i = 0; i < a; i++){ for (i = 0; i < a; i++){
printf("%.2f ", number[i].cislo); printf("%.2f ", number[i].cislo);
} }
if (vys != 1) {
printf("\n"); printf("\n");
}
} }
printf("no input\n"); printf("no input\n");
return 0; return 0;