From 7b38c7fa2a76d912ca45576c06b9f900d77b616c Mon Sep 17 00:00:00 2001 From: Stoycho Kyosev Date: Wed, 19 Oct 2022 13:15:50 +0300 Subject: add Sem03 --- Seminar03/task01.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Seminar03/task01.cpp (limited to 'Seminar03/task01.cpp') diff --git a/Seminar03/task01.cpp b/Seminar03/task01.cpp new file mode 100644 index 0000000..2a2eff3 --- /dev/null +++ b/Seminar03/task01.cpp @@ -0,0 +1,27 @@ +#include +#include +#include + +// Сложност по време: ? +// Сложност по памет: ? +void printAllBinaryNumbers(size_t n) { + std::queue q; + + q.push("1"); + + while(n) { + std::string currentNumber = q.front(); + q.pop(); + + std::cout << currentNumber << " "; + + q.push(currentNumber + "0"); + q.push(currentNumber + "1"); + + n--; + } +} + +int main() { + printAllBinaryNumbers(10); +} \ No newline at end of file -- cgit v1.3.1-23-gd82d