harmadik feladat

This commit is contained in:
Iván Sándor 2022-05-21 14:30:25 +02:00
parent 39125d2d97
commit cbf7bbb57b

27
hf16/3.cpp Normal file
View file

@ -0,0 +1,27 @@
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
// harmadik feladat
vector<int> common(vector<int> a, vector<int> b) {
vector<int> out;
for (int i = 0; i < a.size(); i++) {
for (int j = 0; j < b.size(); j++) {
if (a[i] == b[j]) {
out.push_back(a[i]);
}
}
}
return out;
}
int main() {
vector<int> a = {1,2,3,4,5,6};
vector<int> b = {2,4,6,8,10};
vector<int> out = common(a,b);
for (int i = 0; i < out.size(); i++) {
cout<<out[i]<<" ";
}
}