3.3
Copied!
#include <iostream>
#include <vector>
#include <set>
#include <random>
#include <ctime>
using namespace std;
int main() {
default_random_engine rnd(time(0));
uniform_int_distribution<unsigned> g(10, 50);
vector<int> myVektor;
int n, k = 0;
cout << "n = "; cin >> n;
for (int i = 0; i < n; i ) {
int d = g(rnd);
myVektor.push_back(d);
cout << myVektor[i] << " ";
}
set<int> mySet;
for (int i = 1; i <= 5; i) mySet.insert(i * 10);
cout << endl;
for (int i = 0; i < n; i )
if (mySet.count(myVektor[i])) k ;
cout << k << " ta element topildi." << endl;
system("pause");
return 0;
}
Run on cpp.sh
Copied!