Advertisement
Guest User

main_kalkulator.c

a guest
Jan 24th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. int main ()
  2. {
  3. t_elem *stos=NULL;
  4. //char oper=' ';
  5. //int element;
  6. //int arg1, arg2;
  7.  
  8. push(&stos, 7);
  9. print(&stos);
  10.  
  11.  
  12.  
  13.  
  14. return 0;
  15. }
  16.  
  17. /*while(oper!='q')
  18. {
  19. oper=getc(stdin);
  20. if(isdigit(oper)!=0)
  21. {
  22. ungetc(oper, stdin);
  23. scanf("%d", &element);
  24. push(stos, element);
  25. }
  26. else
  27. switch (oper)
  28. {
  29. case '+':
  30. if((pop(stos, &element))==0)
  31. {
  32. pop(stos, &arg1);
  33. }
  34. else
  35. {
  36. fprintf(stderr, "Stos jest pusty");
  37. }
  38. if((pop(stos, &element))==0)
  39. {
  40. pop(stos, &arg2);
  41. push(stos, arg1+arg2);
  42. printf("%d", arg1+arg2);
  43. }
  44. break;
  45. case '-':
  46. if((pop(stos, &element))==0)
  47. {
  48. pop(stos, &arg1);
  49. }
  50. else
  51. {
  52. fprintf(stderr, "Stos jest pusty");
  53. }
  54. if((pop(stos, &element))==0)
  55. {
  56. pop(stos, &arg2);
  57. push(stos, arg2-arg1);
  58. }
  59. break;
  60. case '*':
  61. if((pop(stos, &element))==0)
  62. {
  63. pop(stos, &arg1);
  64. }
  65. else
  66. {
  67. fprintf(stderr, "Stos jest pusty");
  68. }
  69. if((pop(stos, &element))==0)
  70. {
  71. pop(stos, &arg2);
  72. push(stos, arg1*arg2);
  73. }
  74.  
  75. break;
  76. case '/':
  77. if((pop(stos, &element))==0)
  78. {
  79. pop(stos, &arg1);
  80. }
  81. else
  82. {
  83. fprintf(stderr, "Stos jest pusty");
  84. }
  85. if((pop(stos, &element))==0)
  86. {
  87. pop(stos, &arg2);
  88. push(stos, arg2/arg1);
  89. }
  90. break;
  91. default:
  92. fprintf(stderr, "nieznany operator\n");
  93. return 0;
  94.  
  95. }
  96. }
  97. return 0;
  98. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement