This commit is contained in:
Matej Hajduk 2025-10-15 17:18:52 +02:00
parent eadf9c357b
commit a8d5d8f6b3

View File

@ -12,7 +12,7 @@ struct stack{
};
void print(struct stack *s)
{
for(int i = 0; i < s ->values[i], i++){
for(int i = 0; i < s ->values[i]; i++){
printf("%.2f ", s->values[i]);
}
printf("\n");
@ -36,7 +36,7 @@ int main(){
while(fgets(x, 100, stdin)){
x[strcspn(x, "\n")] = 0;
if (strlen() == 0) continue;
if (strlen(x) == 0) continue;
char *endptr;
float num = strtof(x, &endptr);
@ -47,9 +47,9 @@ int main(){
}
push(&mystack,num);
}
else if(stlen(x) == 1 && strchr("+-/", x[0])) {
else if(strlen(x) == 1 && strchr("+-/", x[0])) {
if (mystack.size < 2){
fprint(stderr, "malo cisel \n");
fprintf(stderr, "malo cisel \n");
return 1;
}
float a = pop(&mystack);
@ -64,10 +64,10 @@ int main(){
fprintf(strderr, "nule pr ideleni \n");
return 1;
}
resut = a / b;
result = a / b;
break;
}
push(&mystak,result);
push(&mystack,result);
}
else{
fprintf(stderr, " zly vstup \n");