Skip to content
Snippets Groups Projects
Commit 2ff97713 authored by paul.albuquer's avatar paul.albuquer
Browse files

added source code postfixe evaluation

parent c3f942b8
No related branches found
No related tags found
No related merge requests found
Pipeline #14890 failed
#include <stdio.h>
#include <stdlib.h>
#include "pile_ptr_int.h"
void main(int argc,char** argv) {
pile stack_nb = pile_creer();
int res,nb1,nb2;
for (int i=1;i<argc;i++) {
if ( argv[i][0] < '0' || '9' < argv[i][0]) {
nb1 = pile_depiler(&stack_nb);
nb2 = pile_depiler(&stack_nb);
}
switch(argv[i][0]) {
case '+':
res = nb2+nb1;
break;
case '-':
res = nb2-nb1;
break;
case 'x':
res = nb2*nb1;
break;
case '/':
res = nb2/nb1;
break;
default :
res = atoi(argv[i]);
}
pile_empiler(&stack_nb,res);
}
printf("%d\n",pile_depiler(&stack_nb));
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment