题解 | #查找#标记数组#
查找
https://www.nowcoder.com/practice/d93db01c2ee44e8a9237d63842aca8aa
#include<iostream> const int N = 100; bool visited[N]; int main() { int n; while (std::cin >> n) { int a, b; visited[N] = {false}; for(int i = 0;i < n;i++) { std::cin >> a; visited[a] = true; } int m; std::cin >> m; for(int i = 0;i < m;i++) { std::cin >> b; if(visited[b] == true) { std::cout << "YES" << std::endl; }else { std::cout << "NO" << std::endl; } } } }