题解 | #查找#

查找

https://www.nowcoder.com/practice/d93db01c2ee44e8a9237d63842aca8aa

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m;
    cin>>n;
    int arr[n];
    for(int i =0;i<n;i++)cin>>arr[i];
    cin>>m;
    while(m--){
        int temp;cin>>temp;
        if(find(arr,arr+n,temp)!=arr+n)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}
// 64 位输出请用 printf("%lld")

还是set好用

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务