Линейный поиск
unknown
c_cpp
7 months ago
582 B
13
Indexable
Never
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; ++i) { cin >> a[i]; } int m; cin >> m; for (int i = 0; i < m; ++i) { int x; cin >> x; bool flag = false; for (int j = 0; j < n; ++j) { if (a[j] == x) { flag = true; break; } } if (flag == true) { cout << "YES" << endl; } else { cout << "NO" << endl; } } return 0; }
Leave a Comment