Solução: Dominó - OBI (Filipe Teles)
From AdonaiMedrado.Pro.Br
Revision as of 12:43, 3 June 2009 by 200.17.147.2 (Talk) (New page: <code lang=cpp> #include <iostream> using namespace std; typedef struct P { int n; int bucha; } peca; int main() { int entrada, esq, dir, teste = 1, cont = 0, i; peca mesa[7]; fo...)
#include <iostream> using namespace std; typedef struct P { int n; int bucha; } peca; int main() { int entrada, esq, dir, teste = 1, cont = 0, i; peca mesa[7]; for (int j = 0; j < 7; j++) { mesa[j].n = 0; mesa[j].bucha = 0; } cin >> entrada; while (entrada) { while(entrada--) { cin >> esq >> dir; if ( (esq == dir) && (!mesa[esq].n) ) { mesa[esq].n = 2; mesa[esq].bucha++; } else { mesa[esq].n++; mesa[esq].bucha = 0; mesa[dir].n++; mesa[dir].bucha = 0; } } i = 0; for (; i < 7; i++) { if (mesa[i].n % 2) cont++; if ( (mesa[i].bucha) || (cont > 2) ) { cout << "Teste " << teste << endl << "nao\n\n"; break; } } if (i == 7) cout << "Teste " << teste << endl << "sim\n\n"; teste++; for (int j = 0; j < 7; j++) { mesa[j].n = 0; mesa[j].bucha = 0; } cont = 0; cin >> entrada; } }