O’ZBEKISTON RESPUBLIKASI DAVLAT SOLIQ QO’MITASI
HUZURIDAGI FISKAL INSTITUTI
Buxgalteriya va iqtisodiyot fakulteti
“Matematika va axborot texnologiyalari” kafedrasi
“Ma’lumotlar tuzilmasi va algoritmi” fanidan
№1 – Labaratoriya ishi
Bajardi: Hamzayev Mirkomil
Qabul qildi: Yusupova Zaynabxon
Guruh: RI-01-21
8-variant
Dastur sharti:
Kiritilgan sonlar ichida kattasini olib tashlash.
Dastur kodi:
class Queue:
def __init__(self):
self.a=[]
def push(self,k):
self.a.append(k)
def pop(self):
t=self.a.pop(0)
return t
def top(self):
return self.a[0]
def size(self):
return len(self.a)
def isEmpty(self):
if (len(self.a)==0):
return True
else:
return False
def print(self):
print(self.a)
nav1=Queue()
n=int(input("n="))
for i in range(n):
p=int(input("son="))
nav1.push(p)
print("Bosh holat=")
nav1.print()
a=nav1.top()
n=nav1.size()
for i in range(n):
b=nav1.pop()
if aa=b
nav1.push(b)
for i in range(n):
b=nav1.pop()
if a==b:
pass
else:
nav1.push(b)
nav1.print()
Natija:
n=4
son=1
son=2
son=3
son=4
dastlabgi holat:
[1, 2, 3, 4]
natija:
[1, 2, 3]
NATIJA:
Do'stlaringiz bilan baham: |