class Nod: def __init__(self,data): class Stiva: def __init__(self,primu=None): self.primu=primu self.lungime=0 def Push(self,data): #adaugara la inceput nod_nou=Nod(data) self.lungime+=1 self.primu=nod_nou def Pop(self): #stergere de la inceput curent=self.primu data=curent self.lungime-=1 print( def size(self): return self.lungime def top(self): return def print(self): curent=self.primu while curent is not None: print( l1=Stiva() l1.Push(1) l1.Push(2) l1.Push(3) l1.Push(4) l1.print() print("Lungimea este :{}\n".format(l1.size())) l1.Pop() print("Lungimea este :{}\n".format(l1.size())) l1.print() print("\n") print( print("\n") l1.print()
Implementarea unei Stive

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.