This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int resolverNPN(char *str){ | |
char *eq = strrev(str); | |
int l = strlen(str); | |
// temporario que armazena a conversão do caracter para o numero tipo inteiro | |
int tmp; | |
// variaveis utiliza para as operações matematicas | |
int x, y, result; | |
stack_t *int_stack; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char *infixToPrefix(char *infix){ | |
//Tamanho da string recebida | |
int l = strlen(infix); | |
//Inverte a string recebida | |
infix = strrev(infix); | |
//Arruma os parenteses que estão errados | |
//depois da operação de reversão | |
for (int i = 0; i < l; i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef NPN_H_INCLUDED | |
#define NPN_H_INCLUDED | |
#include <stdlib.h> | |
//Caso seja um operador retorna 1 se não retorna 0 | |
int isOperator(char c); | |
//Prioridade de operações | |
int getPriority(char c); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char *infixToPostfix(char *infix){ | |
int l = strlen(infix); | |
stack_t *char_stack; | |
stack_initialize(&char_stack, constructor_char, destructor_char); | |
char *output = malloc(l *sizeof(char)); | |
char aux; | |
for (int i = 0; i < l; i++){ | |
//Caso seja um numero coloque direto na variavel outpur |