-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathRonaldo.py
53 lines (34 loc) · 921 Bytes
/
Ronaldo.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
#Bubble sort em ordem descrescente com pilha#
from sys import maxsize
lista = [1,2,3,4,5,6,7,8,9,10]
def bubbleDecrescente(lista):
for i in range(len(lista)-1,0,-1):
for i in range(i):
if lista[i]<lista[i+1]:
aux = lista[i]
lista[i] = lista[i+1]
lista[i+1] = aux
return(lista)
print(bubbleDecrescente(lista))
def criaPilha():
pilha = []
return pilha
def isEmpty(pilha):
return len(pilha) == 0
def push(pilha, item):
pilha.append(item)
def pop(pilha):
if (isEmpty(pilha)):
return str(-maxsize -1)
return pilha.pop()
def peek(pilha):
if (isEmpty(pilha)):
return str(-maxsize -1)
return pilha[len(pilha) - 1]
pilha = criaPilha()
x = []
for i in range(10):
push(pilha, str(lista[i]))
for i in range(10):
x.append((pop(pilha)))
print(x)