add Chapter10

This commit is contained in:
Amar Mahmutbegovic
2024-09-09 20:55:25 +02:00
parent 8673086b40
commit 8ce616c0c9
203 changed files with 302587 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
#include <cstdint>
#include <cstdio>
#include <stm32f072xb.h>
#include <hal.hpp>
#include <uart_stm32.hpp>
#include <retarget.hpp>
#include <algorithm>
#include <array>
int main()
{
hal::init();
hal::uart_stm32 uart(USART2);
uart.init();
retarget::set_stdio_uart(&uart);
std::array<int, 4> arr{5, 3, 4, 1};
const auto print_arr = [&arr](const char* message) {
printf("%s\r\n", message);
for(auto elem : arr) {
printf("%d, ", elem);
}
printf("\r\n");
};
print_arr("Unsorted array:");
std::sort(arr.begin(), arr.end(), [](int a, int b) {
return a < b;});
print_arr("Sorted in ascending order:");
std::sort(arr.begin(), arr.end(), [](int a, int b) {
return a > b;});
print_arr("Sorted in descending order:");
while(true)
{
}
}