Skip to content

Instantly share code, notes, and snippets.

@VergilSkye
Created October 26, 2018 03:34
Show Gist options
  • Save VergilSkye/39d014d351ffb8f80954d976910fc56e to your computer and use it in GitHub Desktop.
Save VergilSkye/39d014d351ffb8f80954d976910fc56e to your computer and use it in GitHub Desktop.
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++)
{
if (infix[i] == '(')
{
infix[i] = ')';
continue;
}
else if (infix[i] == ')')
{
infix[i] = '(';
continue;
}
}
char *prefix = infixToPostfix(infix);
prefix = strrev(prefix);
return prefix;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment