Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main ()
- {
- t_elem *stos=NULL;
- //char oper=' ';
- //int element;
- //int arg1, arg2;
- push(&stos, 7);
- print(&stos);
- return 0;
- }
- /*while(oper!='q')
- {
- oper=getc(stdin);
- if(isdigit(oper)!=0)
- {
- ungetc(oper, stdin);
- scanf("%d", &element);
- push(stos, element);
- }
- else
- switch (oper)
- {
- case '+':
- if((pop(stos, &element))==0)
- {
- pop(stos, &arg1);
- }
- else
- {
- fprintf(stderr, "Stos jest pusty");
- }
- if((pop(stos, &element))==0)
- {
- pop(stos, &arg2);
- push(stos, arg1+arg2);
- printf("%d", arg1+arg2);
- }
- break;
- case '-':
- if((pop(stos, &element))==0)
- {
- pop(stos, &arg1);
- }
- else
- {
- fprintf(stderr, "Stos jest pusty");
- }
- if((pop(stos, &element))==0)
- {
- pop(stos, &arg2);
- push(stos, arg2-arg1);
- }
- break;
- case '*':
- if((pop(stos, &element))==0)
- {
- pop(stos, &arg1);
- }
- else
- {
- fprintf(stderr, "Stos jest pusty");
- }
- if((pop(stos, &element))==0)
- {
- pop(stos, &arg2);
- push(stos, arg1*arg2);
- }
- break;
- case '/':
- if((pop(stos, &element))==0)
- {
- pop(stos, &arg1);
- }
- else
- {
- fprintf(stderr, "Stos jest pusty");
- }
- if((pop(stos, &element))==0)
- {
- pop(stos, &arg2);
- push(stos, arg2/arg1);
- }
- break;
- default:
- fprintf(stderr, "nieznany operator\n");
- return 0;
- }
- }
- return 0;
- }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement