Created
September 4, 2019 00:12
-
-
Save luciocf/9a3ffc6d01e0eefb2ed4c7fe3f4e5297 to your computer and use it in GitHub Desktop.
Comentário Noic OBI 2019 - Fase 2 - Programação Júnior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Comentário Noic OBI 2019 - Fase 2 - Programação Júnior | |
// Jogo dos copos | |
#include <bits/stdc++.h> | |
using namespace std; | |
int main(void) | |
{ | |
int n; | |
char copo; // copo em que a moeda está inicialmente | |
cin >> n >> copo; | |
int A = 0, B = 0, C = 0; | |
if (copo == 'A') A = 1; | |
else if (copo == 'B') B = 1; | |
else C = 1; | |
for (int i = 1; i <= n; i++) | |
{ | |
int operacao; | |
cin >> operacao; | |
if (operacao == 1) | |
swap(A, B); // troca A e B | |
else if (operacao == 2) | |
swap(B, C); // troca B e C | |
else | |
swap(A, C); // troca A e C | |
} | |
if (A == 1) cout << "A\n"; | |
else if (B == 1) cout << "B\n"; | |
else cout << "C\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment