Skip to content

Commit 6981a26

Browse files
authored
Merge pull request #9 from marlonwq/Estrutura-de-repetição
Estrutura de repetição
2 parents 12b4e9b + 62ff051 commit 6981a26

File tree

2 files changed

+57
-0
lines changed
  • Nível 1 - Lógica/3 - Estrutura de Repetição/exercícios/soluções/marlonwq

2 files changed

+57
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int N, casal = 2, triplo = 3, familia = 5, quadruplo = 4;
6+
cin >> N;
7+
string input;
8+
9+
while (true) {
10+
cin >> input;
11+
12+
if (input == "FIM") {
13+
break;
14+
}
15+
16+
if (input == "Casal") {
17+
N -= casal;
18+
} else if (input == "Triplo") {
19+
N -= triplo;
20+
} else if (input == "Quadruplo") {
21+
N -= quadruplo;
22+
} else if (input == "Familia") {
23+
N -= familia;
24+
}
25+
26+
if (N <= 0) {
27+
break;
28+
}
29+
}
30+
31+
if (N <= 0) {
32+
cout << "Pode reservar! Esses quartos cabem todos." << endl;
33+
} else {
34+
cout << "Procure outra pousada." << endl;
35+
}
36+
37+
return 0;
38+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int E, P, ataques = 0;
6+
cin >> E >> P;
7+
8+
while (E > 0 && P > 0) {
9+
E -= P;
10+
P--;
11+
ataques++;
12+
}
13+
14+
if (E > 0) {
15+
cout << "F";
16+
} else {
17+
cout << ataques << endl;
18+
}
19+
}

0 commit comments

Comments
 (0)