-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculadora-polonesa.c
143 lines (116 loc) · 3.88 KB
/
calculadora-polonesa.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* ------------------------------------------------------------------------- */
/* includes */
#include <stdio.h> /* Standard I/O functions */
#include <stdlib.h> /* Miscellaneous functions (rand, malloc, srand)*/
#include <getopt.h> /* get options from system argc/argv */
#include "calculadora-polonesa.h" /* To be created for this template if needed */
/* #include <time.h> */ /* Time and date functions */
/* #include <math.h> */ /* Mathematics functions */
/* #include <string.h> */ /* Strings functions definitions */
/* #include <dlfcn.h> */ /* Dynamic library */
/* #include <malloc.h> */ /* Dynamic memory allocation */
/* #include <unistd.h> */ /* UNIX standard function */
/* #include <limits.h> */ /* Various C limits */
/* #include <ctype.h> */ /* Character functions */
/* #include <errno.h> */ /* Error number codes errno */
/* #include <signal.h> */ /* Signal processing */
/* #include <stdarg.h> */ /* Functions with variable arguments */
/* #include <pthread.h> */ /* Parallel programming with threads */
/* #include <fcntl.h> */ /* File control definitions */
/* #include <termios.h> */ /* Terminal I/O definitions POSIX */
/* #include <sys/stat.h> */ /* File status and information */
/* #include <float.h> */ /* Float constants to help portability */
/* #include <setjmp.h> */ /* Bypass standard function calls and return */
/* #include <stddef.h> */ /* Various types and MACROS */
/* #include <SWI-Prolog.h> */ /* Prolog integration with C */
/* #include <ncurses.h> */ /* Screen handling and optimisation functions */
/* #include <allegro.h> */ /* A game library for graphics, sounds, etc. */
/* #include <libintl.h> */ /* Internationalization / translation */
/* #include <locale.h> */ /* MACROS LC_ for location specific settings */
int main(int argc, char *argv[])
{
exN_init(); /* initialization function */
return 0;
}
/* Write your functions here... */
void Calc_init(void)
{
return;
}
/* ---------------------------------------------------------------------- */
int valida(char *s)
{
const char sval[]="0123456789 +-*/";
errno=0;
}
/* ---------------------------------------------------------------------- */
info_t *pop(pilha_t **p)
{
pilha_t *remove = NULL;
if(empty(*p) != 1) {
remove = *p;
*p = remove->prox;
}
else
printf("Pilha vazia\n");
return remove;
}
/* ---------------------------------------------------------------------- */
void push(pilha_t **p, info_t i)
{
pilha_t *novo = malloc(sizeof(pilha_t)); //Aloca a memoria necessaria
if(novo) //Se a memoria foi alocada
{
novo->val = i;
novo->prox = p;
return novo;
}
else
printf("Erro ao alocar memoria\n");
return NULL;
}
/* ---------------------------------------------------------------------- */
int empty(pilha_t *p)
{
if(p == NULL)
return 1;
else
return 0;
}
/* ---------------------------------------------------------------------- */
void clean(pilha_t **p)
{
;
}
/* ---------------------------------------------------------------------- */
int size(pilha_t *p)
{
int count = 0;
while(empty(p) != 1)
{
count++;
p = p->prox;
}
return count;
}
/* ---------------------------------------------------------------------- */
info_t *top(pilha_t *p)
{
while(empty(p) != 1)
{
return p;
}
}
/* ---------------------------------------------------------------------- */
void print(pilha_t *p)
{
printf("\n\t---Pilha---\n");
while(p)
{
printf("\t%.2f\n", p->val);
p = p->prox;
}
}
/* ------------------------------------------------------------------------- */
/* vi: set ai et ts=4 sw=4 tw=0 wm=0 fo=croql : C config for Vim modeline */
/* Template by Dr. Beco <rcb at beco dot cc> Version 20180716.101436 */