Skip to content

Commit 1f28edb

Browse files
committed
Added code for generating binary numbers
1 parent f1cfa4e commit 1f28edb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Solutions/generatebinQueue.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
void binaryNumbersQueue(int n){
5+
queue<string> bin;
6+
bin.push("1");
7+
while(n != 0){
8+
string num = bin.front();
9+
bin.pop();
10+
cout << num << " ";
11+
n--;
12+
bin.push(num + "0");
13+
bin.push(num + "1");
14+
}
15+
}
16+
int main(){
17+
int size;
18+
cin >> size;
19+
binaryNumbersQueue(size);
20+
}

0 commit comments

Comments
 (0)