题解 | #查找#
查找
https://www.nowcoder.com/practice/d93db01c2ee44e8a9237d63842aca8aa
#include <iostream> using namespace std; int main() { int n; while (scanf("%d", &n) != EOF) { int arr[n]; for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } int m; scanf("%d", &m); for (int j = 0; j < m; j++) { int x; int tag = -1; scanf("%d", &x); for (int i = 0; i < n; i++) { if (x == arr[i]) { tag = 1; printf("YES\n"); break; } } if (tag == -1) { printf("NO\n"); } } } }