/
lyapdy
/
Object_oriented_programming_cpp_318
Обзор
Документация
Войти
/
lyapdy
/
Object_oriented_programming_cpp_318
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
lab4/task_5.h
45 строк
1 KB
danillyapunov
lab4
18 июн 2025, 16:19
18 июн 2025, 16:19
d3a17e8
Код
Авторство
О чём код?
#include <iostream> #include <ctime> #include <random> // ��� std::random_device � std::mt19937 #ifndef TASK_5_H #define TASK_5_H template <typename F> // 蠡��� �㭪樨 ��� ���������� ���ᨢ� ��砩�묨 ��� � Task_5 F fillArr(F* array, int size) { srand (time(NULL)); for (int i = 0; i < size; ++i) { array[i] = 100 * static_cast<double>(rand()) / static_cast<double>(rand()); } return *array; } template <typename S> // 蠡��� �㭪�� ��� ����� ���ᨢ� ����쪮� � Task_5 S bubbleSort(S array[], int size) { while(size--) { bool swapped = false; for(int i = 0; i < size; i++) { if(array[i] > array[i + 1]) { std::swap(array[i], array[i + 1]); swapped = true; } } if(swapped == false) break; } return *array; } template <typename P> // 蠡��� �㭪�� ��� ���⠭�� ���ᨢ� � Task_5 void printArr(P* array, int size) { for (int col = 0; col < size; ++col) { std::cout << (*(array + col)) << " "; } std::cout << '\n'; } void task_5(); #endif // TASK_5_H