diff --git a/Лаб6/Задание/lab6.pdf b/Лаб6/Задание/lab6.pdf new file mode 100644 index 0000000..e7acfad Binary files /dev/null and b/Лаб6/Задание/lab6.pdf differ diff --git a/Лаб6/Сайт/index.html b/Лаб6/Сайт/index.html new file mode 100644 index 0000000..350a8db --- /dev/null +++ b/Лаб6/Сайт/index.html @@ -0,0 +1,187 @@ + + + + + + + Books Information + + + + +
+ + + +
+
+ +
+
+ +
+
+ + + +
+
+

Поиск книг:

+ + + +
+ + + +
+ + + + + +
+
+ + +
+
+ +
+ +

Информация о книгах

+ + + + + + + + + + + + + + +
НазваниеАвторЖанрДата изданияКоличество страницВозраст
+ +
+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/Лаб6/Сайт/script.js b/Лаб6/Сайт/script.js new file mode 100644 index 0000000..85dd30b --- /dev/null +++ b/Лаб6/Сайт/script.js @@ -0,0 +1,128 @@ +function generateRandomDate() { + const year = Math.floor(Math.random() * (2024 - 1900)) + 1900; + const month = Math.floor(Math.random() * 12) + 1; + const day = Math.floor(Math.random() * 28) + 1; + return new Date(year, month - 1, day); +} + +function generateRandomAuthor() { + const names = [ + 'Александр', + 'Екатерина', + 'Дмитрий', + 'Анна', + 'Иван', + 'Мария', + 'Сергей', + 'Ольга', + 'Павел', + 'Наталья', + ]; + const surnames = [ + 'Иванов', + 'Петров', + 'Смирнов', + 'Кузнецов', + 'Васильев', + 'Соколов', + 'Михайлов', + 'Новиков', + 'Федоров', + 'Морозов', + ]; + const randomName = names[Math.floor(Math.random() * names.length)]; + const randomSurname = surnames[Math.floor(Math.random() * surnames.length)]; + return { + name: randomName, + surname: randomSurname, + }; +} + +function generateRandomBook() { + return { + title: 'Книга ' + Math.floor(Math.random() * 1000), + genre: [ + 'Фантастика', + 'Роман', + 'Детектив', + 'Фэнтези', + 'Приключения', + 'Исторический роман', + 'Триллер', + 'Поэзия', + 'Научно-популярная литература', + 'Юмористическая проза', + ][Math.floor(Math.random() * 6)], + publishDate: generateRandomDate(), + author: generateRandomAuthor(), + pageCount: Math.floor(Math.random() * 500) + 100, + }; +} + +function createBooksArray(N) { + const books = []; + for (let i = 0; i < N; i++) { + books.push(generateRandomBook()); + } + return books; +} + +function findBooksByAuthor(books, authorLastName) { + const filteredBooks = books.filter((book) => { + return book.author.surname === authorLastName; + }); + + return filteredBooks; +} + +function findBooksByGenre(books, genre) { + const filteredBooks = books.filter((book) => book.genre === genre); + + return filteredBooks; +} + +function findBooksByPublishYearRange(books, startYear, endYear) { + const filteredBooks = books.filter((book) => { + const publishYear = book.publishDate.getFullYear(); + return publishYear >= startYear && publishYear <= endYear; + }); + + return filteredBooks; +} + +function removeBooksPageCount(books, minPageCount) { + for (let i = 0; i < books.length; i++) { + if (books[i].pageCount < minPageCount) { + delete books[i].pageCount; + } + } + + return books; +} + +function addAgeInfoToBooks(books) { + const currentDate = new Date(); + books.forEach((book) => { + const yearsSincePublication = + currentDate.getFullYear() - book.publishDate.getFullYear(); + book.age = yearsSincePublication; + }); + + return books; +} + +// const booksArray = createBooksArray(10); +// console.log('Initial array of books:'); +// displayBooks(booksArray); + +// findBooksByAuthor(booksArray, 'Smith'); +// findBooksByGenre(booksArray, 'Fantasy'); +// findBooksByPublishYearRange(booksArray, 2000, 2010); + +// booksArray = removeBooksByPageCount(booksArray, 200); +// console.log('Array after removing books by page count:'); +// displayBooks(booksArray); + +// booksArray = addAgeInfoToBooks(booksArray); +// console.log('Array after adding age info:'); +// displayBooks(booksArray); diff --git a/Лаб7/Задание/lab7.pdf b/Лаб7/Задание/lab7.pdf new file mode 100644 index 0000000..98eb4f3 Binary files /dev/null and b/Лаб7/Задание/lab7.pdf differ diff --git a/Лаб7/Сайт/index.html b/Лаб7/Сайт/index.html new file mode 100644 index 0000000..47f62a0 --- /dev/null +++ b/Лаб7/Сайт/index.html @@ -0,0 +1,90 @@ + + + + + + + Лабораторная работа No7 + + + +
+ + + + + + +

+ + +

+

Характеристики

+ + + + + + +

+

Варианты функции

+ + + + + + +

+ +
+ + + + + + \ No newline at end of file diff --git a/Лаб7/Сайт/script.js b/Лаб7/Сайт/script.js new file mode 100644 index 0000000..d0f1860 --- /dev/null +++ b/Лаб7/Сайт/script.js @@ -0,0 +1,108 @@ +function f_1(x) { + return x + (x * x * x - Math.log(x)) / Math.sqrt(x + 5); +} + +function f_2(x) { + return Math.pow(Math.sin(x), 2) - Math.abs(5 - Math.log10(x - 4)); +} + +function f_3(x) { + return Math.exp(x - 2) + (x * x * x + 2 * x) / 4; +} + +function memoize(fn) { + const cache = new Map(); + const memoized = function (...args) { + const key = JSON.stringify(args); + if (cache.has(key)) { + console.log('Using cache'); + return cache.get(key); + } + const result = fn(...args); + cache.set(key, result); + return result; + }; + + memoized.countMemoized = function () { + return cache.size; + }; + + return memoized; +} + +function debug(fn) { + return function (...args) { + const result = fn(...args); + + console.log( + `Called ${ + fn.name + } at ${new Date().toISOString()} with args ${args}. Result: ${result}` + ); + + return result; + }; +} + +function countCalls(fn) { + let count = 0; + const wrapped = function (...args) { + count++; + return fn(...args); + }; + + wrapped.countCalls = function () { + return count; + }; + + wrapped.resetCount = function () { + count = 0; + }; + + return wrapped; +} + +function findMin(fn, start, end, h) { + let min = Infinity; + for (let x = start; x < end; x += h) { + const curr = fn(x); + if (curr < min) { + min = curr; + } + } + + return min; +} + +function countPositive(fn, start, end, h) { + let count = 0; + for (let x = start; x < end; x += h) { + if (fn(x) > 0) { + count++; + } + } + + return count; +} + +function isMonotonous(fn, start, end, h) { + let prev = fn(start); + for (let x = start; x < end; x += h) { + const curr = fn(x); + if (curr < prev) { + return false; + } + prev = curr; + } + + return true; +} + +function calculateCharacteristics(fn, start, end, h, characteristics) { + chars = []; + for (let i = 0; i < characteristics.length; i++) { + chars.push(characteristics[i](fn, start, end, h)); + } + + return chars; +}