-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1025.cpp
More file actions
62 lines (42 loc) · 1.14 KB
/
1025.cpp
File metadata and controls
62 lines (42 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int numeroDeMarmores, numeroDeConsultas;
int input,count = 0;
cin>>numeroDeMarmores;
cin>>numeroDeConsultas;
while(numeroDeMarmores != 0 && numeroDeConsultas != 0){
vector<int> marmores;
vector<int> consultas;
cout<< "CASE# " << ++count << ":\n";
for (int i = 0; i < numeroDeMarmores; i++)
{
cin>>input;
marmores.push_back(input);
}
sort(marmores.begin(),marmores.end());
for (int i = 0; i < numeroDeConsultas; i++)
{
cin>>input;
consultas.push_back(input);
}
// buscar os indices de cada consulta
for (int i = 0; i < numeroDeConsultas; i++)
{
bool encontrado = false;
input = consultas[i];
for (int j = 0; j < numeroDeMarmores; j++) {
if(marmores[j] == input){
cout<< input << " found at " << j + 1 << endl;
encontrado = true;
break;
}
}
if(!encontrado) cout<< input << " not found\n";
}
cin>>numeroDeMarmores;
cin>>numeroDeConsultas;
}
}