26 lines
657 B
C
26 lines
657 B
C
#include "calculator.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main() {
|
|
char infix[100], *postfix = NULL;
|
|
printf("Zadajte matematický výraz: ");
|
|
fgets(infix, sizeof(infix), stdin);
|
|
|
|
// Odstránenie nového riadku, ktorý fgets môže pridať
|
|
infix[strcspn(infix, "\n")] = 0;
|
|
|
|
// Konverzia na postfixovú notáciu
|
|
infix_na_postfix(infix, &postfix);
|
|
printf("Postfixová notácia: %s\n", postfix);
|
|
|
|
// Vyhodnotenie výrazu
|
|
double vysledok = vyhodnot_postfix(postfix);
|
|
printf("Výsledok: %.2f\n", vysledok);
|
|
|
|
// Uvoľnenie alokovanej pamäte pre postfix
|
|
free(postfix);
|
|
|
|
return 0;
|
|
}
|