-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
42 lines (30 loc) · 690 Bytes
/
Copy pathmain.cpp
File metadata and controls
42 lines (30 loc) · 690 Bytes
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include "queue.cpp"
using namespace std;
void primes(int n) {
Queue<long long> q2, q3, q5;
long long x = 1;
//cout << x << " ";
q2.push(2);
q3.push(3);
q5.push(5);
for (int i = 0; i < n; i++) {
x = min(q2.front(), min(q3.front(), q5.front()));
cout << x << " ";
if (x == q2.front()) q2.pop();
if (x == q3.front()) q3.pop();
if (x == q5.front()) q5.pop();
q2.push(x * 2);
q3.push(x * 3);
q5.push(x * 5);
}
cout << endl;
}
int main() {
setlocale(LC_ALL, "");
int n;
cout << "Ââåäèòå n: ";
cin >> n;
primes(n);
return 0;
}