Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <vector>
- void Erase(std::vector<int>& v, int to_erase) {
- int j = 0;
- for (int i = 0; i < v.size(); i++) {
- if (v[i] != to_erase) {
- v[j++] = v[i];
- }
- }
- v.erase(v.begin() + j, v.end());
- }
- void Print(const std::vector<int>& v) {
- for (int i = 0; i < v.size(); ++i) {
- std::cout << v[i] << " ";
- }
- std::cout << std::endl;
- }
- int main0() {
- int n = 0;
- std::cin >> n;
- std::vector<int> v(n);
- for (int i = 0; i < n; ++i) {
- std::cin >> v.operator[](i);
- }
- int to_erase = 0;
- std::cin >> to_erase;
- Erase(v, to_erase);
- Print(v);
- return 0;
- }
- int main() {
- int n = 0;
- std::cin >> n;
- std::vector<int> v(n);
- for (int i = 0; i < n; ++i) {
- std::cin >> v[i];
- }
- std::vector<int>::iterator it = std::lower_bound(v.begin(), v.end(), 5);
- std::cout << it - v.begin() << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement