#include <iostream> #include <vector> using namespace std; int is_in(vector<int>& a, int b) { for (int i = 0; i < a.size(); ++i) if (a[i] == b) return 0; a.push_back(b); cout << b << ' '; return 1; } int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { int t; cin >> t; is_in(a, t); } } Код #include <iostream> #include <vector> using namespace std; int is_in(vector<int>& a, int b) { for (int i = 0; i < a.size(); ++i) if (a[i] == b) return 0; a.push_back(b); cout << b << ' '; return 1; } int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { int t; cin >> t; is_in(a, t); } }
#include <bits/stdc++.h> int main() { std::uint32_t n{}; std::vector<std::uint32_t> v{}; std::cin.ignore(6, '\n'); while (std::cin >> n) { if (v.end() == std::find(v.begin(), v.end(), n)) { v.push_back(n); } } for (const auto x : v) std::cout << x << ' '; } C #include <bits/stdc++.h> int main() { std::uint32_t n{}; std::vector<std::uint32_t> v{}; std::cin.ignore(6, '\n'); while (std::cin >> n) { if (v.end() == std::find(v.begin(), v.end(), n)) { v.push_back(n); } } for (const auto x : v) std::cout << x << ' '; }