Skip to content

Commit 56ba3b5

Browse files
committed
Vetores e Matrizes - Exercícios + Jogo
1 parent 192f1f0 commit 56ba3b5

File tree

14 files changed

+209
-0
lines changed

14 files changed

+209
-0
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <iostream>
2+
#include <vector>
3+
using namespace std;
4+
5+
int main() {
6+
int N, C;
7+
cin >> N;
8+
int caixas[N];
9+
for (int i = 0; i < N; i++) {
10+
cin >> caixas[i];
11+
}
12+
cin >> C;
13+
for (int i = 0; i < N; i++) {
14+
if (caixas[i] == C) {
15+
cout << C << endl;
16+
return 0;
17+
}
18+
}
19+
cout << -1 << endl;
20+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int N, Y;
6+
cin >> N;
7+
8+
int habilidades[N];
9+
int identificadores[N];
10+
11+
for (int i = 0; i < N; i++) {
12+
cin >> habilidades[i];
13+
}
14+
15+
for (int i = 0; i < N; i++) {
16+
cin >> identificadores[i];
17+
}
18+
19+
cin >> Y;
20+
21+
bool encontrou = false;
22+
for (int i = 0; i < N; i++) {
23+
if (habilidades[i] == Y) {
24+
cout << identificadores[i] << " ";
25+
encontrou = true;
26+
}
27+
}
28+
29+
if (!encontrou) {
30+
cout << "Nenhum";
31+
}
32+
33+
cout << endl;
34+
return 0;
35+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int N, S, pulos = 0;
6+
cin >> N;
7+
8+
int obstaculos[N];
9+
10+
for (int i = 0; i < N; i++) {
11+
cin >> obstaculos[i];
12+
}
13+
14+
cin >> S;
15+
16+
for (int i = 0; i < N; i++) {
17+
if (obstaculos[i] > S) {
18+
break;
19+
}
20+
pulos++;
21+
}
22+
23+
cout << pulos << endl;
24+
cout << (pulos == N ? 1 : 0) << endl;
25+
26+
return 0;
27+
}

0 commit comments

Comments
 (0)