Skip to content

Commit 1297e13

Browse files
authored
Merge pull request #10 from marlonwq/Estrutura-de-repetição
Mais exercícios Loops
2 parents 6981a26 + c8d4566 commit 1297e13

File tree

6 files changed

+87
-0
lines changed

6 files changed

+87
-0
lines changed
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+
using namespace std;
3+
4+
int main() {
5+
int P;
6+
cin >> P;
7+
for (int i = 1; i <= P; i++) {
8+
9+
for (int j = 0; j < P - i; j++) {
10+
cout << ">";
11+
}
12+
13+
for (int j = 0; j < i; j++) {
14+
cout << "#";
15+
}
16+
cout << endl;
17+
}
18+
19+
return 0;
20+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int T;
6+
cin >> T;
7+
8+
bool alarme = false;
9+
int P;
10+
11+
while (true) {
12+
cin >> P;
13+
if (P == 0) break;
14+
if (P > T) alarme = true;
15+
}
16+
17+
if (alarme) {
18+
cout << "ALARME" << endl;
19+
} else {
20+
cout << "O Havai pode dormir tranquilo" << endl;
21+
}
22+
23+
return 0;
24+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int N;
6+
cin >> N;
7+
8+
int level = 1;
9+
10+
for (int i = 0; i < N; i++) {
11+
char tipo;
12+
cin >> tipo;
13+
14+
if (tipo == 't') {
15+
int q;
16+
cin >> q;
17+
level += q;
18+
} else if (tipo == 'm') {
19+
int f;
20+
cin >> f;
21+
cout << "Combate iniciado" << endl;
22+
23+
if (level >= f) {
24+
level += 1;
25+
cout << "VITORIA" << endl;
26+
} else {
27+
cout << "Derrota! Fim da aventura" << endl;
28+
return 0;
29+
}
30+
} else if (tipo == 'b') {
31+
int c;
32+
cin >> c;
33+
level -= c;
34+
if (level < 0)
35+
level = 0;
36+
}
37+
38+
if (level >= 5) {
39+
cout << "Aventura concluida" << endl;
40+
return 0;
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)