Created
June 22, 2015 06:14
-
-
Save rogerioagjr/5c2b8262c5247af60b41 to your computer and use it in GitHub Desktop.
Copa do Mundo
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
#include <cstdio> | |
#define MAXN 20 | |
char gan[MAXN]; | |
int main(){ | |
// primeiro preencho as oitavas | |
for(int i=1; i<=8; i++){ | |
// leio e salvo o placar do jogo i | |
int a, b; | |
scanf("%d %d", &a, &b); | |
// e salvo o vencedor em gan[i] | |
if(a>b) gan[i]=(i-1)*2+'A'; | |
else gan[i]=(i-1)*2+'B'; | |
} | |
// preencho as quartas | |
for(int i=9; i<=12; i++){ | |
// leio e salvo o placar | |
int a, b; | |
scanf("%d %d", &a, &b); | |
// e vejo quem ganhou entre os ganhadores dos jogos | |
// (i-8)*2-1 e (i-8)*2 | |
if(a>b) gan[i]=gan[(i-8)*2-1]; | |
else gan[i]=gan[(i-8)*2]; | |
} | |
// preencho as semis | |
for(int i=13; i<=14; i++){ | |
// leio e salvo o placar | |
int a, b; | |
scanf("%d %d", &a, &b); | |
// e vejo quem ganhou entre os ganhadores dos jogos | |
// (i-12)*2+7 e (i-12)*2+8 | |
if(a>b) gan[i]=gan[(i-12)*2+7]; | |
else gan[i]=gan[(i-12)*2+8]; | |
} | |
// resta apenas o resultado da final | |
// leio o placar | |
int a, b; | |
scanf("%d %d", &a, &b); | |
// e imrimo quem ganhou entre os vencedores das duas semis | |
if(a>b) printf("%c\n", gan[13]); | |
else printf("%c\n", gan[14]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment