首页 > 试题广场 >

查找

[编程题]查找
  • 热度指数:33758 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
输入数组长度 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
头像 潇尘
发表于 2021-03-18 17:13:09
使用map时间复杂度为O(m) #include <iostream> #include <map> using namespace std; int main() { int n; int m; while(cin>>n) { 展开全文
头像 帅呆呆~
发表于 2022-03-06 14:27:38
#include<cstdio> #include <algorithm> #include <string> #include <iostream> #include <cstring> using namespace std; con 展开全文
头像 易水寒learning
发表于 2022-01-17 19:29:47
线性查找 #include <iostream> #include <cstdio> #include <algorithm> using namespace std; const int MAX=100; int arr[MAX]; bool LinSear 展开全文
头像 牛牛客小菜
发表于 2021-08-21 12:41:46
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; bool Find(int a[],int n,int target){     in 展开全文
头像 asaboppfarr
发表于 2021-09-28 23:00:28
#include<iostream> #include<algorithm> using namespace std; int main(){ int n,m; while(cin>>n){ int a[n]; fo 展开全文
头像 T790T
发表于 2024-08-06 23:08:38
#include <iostream> using namespace std; int main() { int a,b,tmp; int x[100],y[100]; while(cin>>a){ for(int i=0;i<a 展开全文
头像 爱吃鱼的大菠萝在debug
发表于 2025-03-16 20:43:04
#include <iostream> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) 展开全文
头像 渺小小螃蟹
发表于 2021-05-10 13:23:45
#include<stdio.h> #include<stdbool.h> const int max=100; int arr[max]; bool linearsearch(int n,int target) { for(int i=0;i<n;i++) 展开全文
头像 牛客231434934号
发表于 2025-03-14 19:22:59
#include <iostream> #include<algorithm> #include<vector> #include<map> #include<string> using namespace std;//find(begin 展开全文
头像 在考古的小鱼干很有气魄
发表于 2023-03-18 12:02:04
#include <bits/stdc++.h> #define INF 0x3f3f3f3f using namespace std; int main(){ int n,m,tmp; vector<int> a,b; cin>>n; for(int 展开全文

问题信息

难度:
163条回答 12133浏览

热门推荐

通过挑战的用户

查看代码
查找