Viết chương trình quản lí các bài hát trong một đĩa CD hay mớt play list, sử dụng cấu trúc LinkedList
from LinkedList import LinkedList
def nhapDL():
ds_bai_hat = LinkedList()
n = int(input("Nhập số lượng bài hát: "))
for i in range(n):
ten_bai = input(f"Nhập tên bài hát thứ {i+1}: ")
ds_bai_hat.append(ten_bai)
return ds_bai_hat
def timBai(ds_bai_hat, ten_bai):
result = ds_bai_hat.find(ten_bai)
if result is not None:
print(f"Bài hát '{ten_bai}' được tìm thấy ở vị trí đầu tiên: {ds_bai_hat.__str__().index(ten_bai) // 4 + 1}")
else:
print(f"Không tìm thấy bài hát '{ten_bai}'")
def inTT(ds_bai_hat):
print("Danh sách bài hát trên đĩa CD hay playlist:")
print(ds_bai_hat)
from quan_ly_cd import nhapDL, timBai, inTT
def main():
ds_bai_hat = nhapDL()
while True:
print("====================================")
print("1. Tìm bài hát")
print("2. In danh sách bài hát")
print("3. Thoát")
choice = int(input("Nhập lựa chọn của bạn: "))
if choice == 1:
ten_bai = input("Nhập tên bài hát cần tìm: ")
timBai(ds_bai_hat, ten_bai)