Python:
class book:
def __init__(self, author, name, date):
self.author = author
self.name = name
self.date = date
def print(self):
print(self.name, self.author, self.date)
book1 = book("абоба", "математика 8 класс", 1951)
book2 = book("абоба", "информатика 8 класс", 1992)
book3 = book("абоба", "математика 10 класс", 1991)
book4 = book("абоба1", "математика 10 класс", 1994)
book5 = book("абоба1", "информатика 10 класс", 1955)
book6 = book("абоба1", "информатика 11 класс", 1993)
book7 = book("абоба", "физика 8 класс", 1952)
book8 = book("абоба", "информатика 8 класс", 1871)
book9 = book("абоба1", "физика 8 класс", 1951)
book10 = book("абоба1", "физика 8 класс", 1971)
library = [book1, book2, book3, book4, book5, book6, book7, book8, book9, book10]
# a
author = "абоба" # автор, книги которого ищем
print("а)")
for i in range(len(library)):
if library[i].author == author and library[i].date >= 1960:
print(library[i].name)
# б
print("б)")
for k in library[i].name.split():
if k == 'информатика':
library[i].print()
# в
print("в)")
for i in range(len(library) - 1):
for j in range(i + 1, len(library)):
if library[i].author == library[j].author and library[i].name == library[j].name:
library[j].print()
===== PascalABC.NET =====
procedure SortShell<T>(a: array of T);
where T: IComparable<T>;
// сортировка по Шеллу
begin
var n := a.Length;
var d := n div 2;
while d > 0 do
var k := True;
while k do
k := False;
for var i := 0 to n - d - 1 do
if a[i].CompareTo(a[i + d]) > 0 then begin
Swap(a[i], a[i + d]);
k := True
end
end;
d := d div 2
var a := ArrRandom(10, -20, 20); a.Println;
SortShell(a); a.Println
end.
Python:
class book:
def __init__(self, author, name, date):
self.author = author
self.name = name
self.date = date
def print(self):
print(self.name, self.author, self.date)
book1 = book("абоба", "математика 8 класс", 1951)
book2 = book("абоба", "информатика 8 класс", 1992)
book3 = book("абоба", "математика 10 класс", 1991)
book4 = book("абоба1", "математика 10 класс", 1994)
book5 = book("абоба1", "информатика 10 класс", 1955)
book6 = book("абоба1", "информатика 11 класс", 1993)
book7 = book("абоба", "физика 8 класс", 1952)
book8 = book("абоба", "информатика 8 класс", 1871)
book9 = book("абоба1", "физика 8 класс", 1951)
book10 = book("абоба1", "физика 8 класс", 1971)
library = [book1, book2, book3, book4, book5, book6, book7, book8, book9, book10]
# a
author = "абоба" # автор, книги которого ищем
print("а)")
for i in range(len(library)):
if library[i].author == author and library[i].date >= 1960:
print(library[i].name)
# б
print("б)")
for i in range(len(library)):
for k in library[i].name.split():
if k == 'информатика':
library[i].print()
# в
print("в)")
for i in range(len(library) - 1):
for j in range(i + 1, len(library)):
if library[i].author == library[j].author and library[i].name == library[j].name:
library[i].print()
library[j].print()
===== PascalABC.NET =====
procedure SortShell<T>(a: array of T);
where T: IComparable<T>;
// сортировка по Шеллу
begin
var n := a.Length;
var d := n div 2;
while d > 0 do
begin
var k := True;
while k do
begin
k := False;
for var i := 0 to n - d - 1 do
if a[i].CompareTo(a[i + d]) > 0 then begin
Swap(a[i], a[i + d]);
k := True
end
end;
d := d div 2
end
end;
begin
var a := ArrRandom(10, -20, 20); a.Println;
SortShell(a); a.Println
end.