Задание 1
https://godbolt.org/z/8fPxq6757
Задание 2
https://godbolt.org/z/zf9eGWs6j
Задание 3
https://godbolt.org/z/Mrfh8T7oW