-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPYC.py
67 lines (53 loc) · 1.63 KB
/
PYC.py
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
class Pila():
def __init__(self):
self.contenido = []
self.cantidad = len(self.contenido)
def revisarActual(self):
return self.contenido[self.cantidad-1]
def obtener(self):
if self.cantidad != 0:
salida = self.contenido[self.cantidad-1]
self.contenido.pop()
self.cantidad = len(self.contenido)
return salida
def eliminar(self):
if self.cantidad != 0:
self.contenido.pop()
self.cantidad = len(self.contenido)
def insertar(self, elemento):
self.contenido.append(elemento)
self.cantidad = len(self.contenido)
def vaciar(self):
self.cantidad = 0
self.contenido = []
class Cola():
def __init__(self):
self.contenido = []
self.cantidad = len(self.contenido)
def actual(self):
return self.contenido[0]
def eliminar(self):
if self.cantidad != 0:
self.contenido.pop(0)
self.cantidad = len(self.contenido)
def obtener(self):
salida = self.contenido[0]
self.contenido.pop(0)
self.cantidad = len(self.contenido)
return salida
def ingresar(self, elemento):
self.contenido.append(elemento)
self.cantidad = len(self.contenido)
def vaciar(self):
self.cantidad = 0
self.contenido = []
def vacia(self):
if self.cantidad == 0:
return True
else:
return False
def existe(self, elemento):
if elemento in self.contenido:
return True
else:
return False