Website Summary Files Commits Branches @commit @diff @stats
path: root / Seminar03 / task01.cpp
blob: 2a2eff352a3f4c5de5c33531e5d81134cedc40ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<iostream>
#include<queue>
#include<string>

// Сложност по време: ?
// Сложност по памет: ?
void printAllBinaryNumbers(size_t n) {
    std::queue<std::string> 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);
}