BUPT复试专题—查找(2011)

https://www.nowcoder.com/practice/d93db01c2ee44e8a9237d63842aca8aa?tpId=67&tqId=29646&tPage=0&ru=/kaoyan/retest/1005&qru=/ta/bupt-kaoyan/question-ranking

题目描述

输入数组长度 n 输入数组      a[1...n] 输入查找个数m 输入查找数字b[1...m]   输出 YES or NO  查找有则YES 否则NO 。

输入描述:

输入有多组数据。
每组输入n,然后输入n个整数,再输入m,然后再输入m个整数(1<=m,n<=100)。

输出描述:

如果在n个数组中输出YES否则输出NO。
示例1

输入

5
1 5 2 4 3
3
2 5 6

输出

YES
YES
NO



查找签到题
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
    int num;
    while(scanf("%d",&num)!=EOF)
    {
        int i=0,j=0,donser[101],n,temp,lable=0;
        while(i++<num)
        {
            scanf("%d",&donser[i]);
        }
        scanf("%d",&n);
        while(j++<n)
        {
            scanf("%d",&temp);
            for(int k=1;k<=num;k++)
            {
                if(donser[k]==temp)
                    lable=1;
            }
            if(lable==1)
                cout<<"YES"<<endl;
            if(lable==0)
                cout<<"NO"<<endl;
            lable=0;
        }
    }
    return 0;    
}


原文地址:https://www.cnblogs.com/dzzy/p/8260695.html