- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmissing-number.cpp
More file actions
Latest commit
34 lines (27 loc) · 784 Bytes
/
Copy pathmissing-number.cpp
File metadata and controls
34 lines (27 loc) · 784 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
#include<iostream>
#include<vector>
#include<algorithm>
intmain() {
int num;
std::vector<int> vector1;
std::cout << "Please enter a sequence of numbers to find the missing numbers among them (0 to stop): ";
while (true) {
std::cin >> num;
if (num == 0) {
break;
}
vector1.push_back(num);
}
std::vector<int> vector2;
for (int i = vector1[0]; i < vector1.back(); i++) {
if (std::find(vector1.begin(), vector1.end(), i) == vector1.end()) {
vector2.push_back(i);
}
}
std::cout << "The missing numbers are:";
for (int missingNum : vector2) {
std::cout << "" << missingNum;
}
std::cout << std::endl;
return0;
}