#include <iostream> using namespace std; int check(int a, int tab[18]) { int counter = 0; for (int i = 0; i < 18; i++) { if (tab[i] == a) { counter++; } } return counter; } int main() { int Alg[18], Baj[18]; int sumAlg = 0, sumBaj = 0; int checkAlg, checkBaj; for (int i = 0; i < 18; i++) { cin >> Alg[i]; sumAlg = sumAlg + Alg[i]; } for (int i = 0; i < 18; i++) { cin >> Baj[i]; sumBaj = sumBaj + Baj[i]; } if (sumAlg > sumBaj) { cout << "Algosia"; } else if (sumAlg < sumBaj) { cout << "Bajtek"; } else if (sumAlg == sumBaj) { for (int i = 9; i > 0; i--) { checkAlg = check(i, Alg); checkBaj = check(i, Baj); if (checkAlg > checkBaj) { cout << "Algosia"; break; } else if (checkAlg < checkBaj) { cout << "Bajtek"; break; } else if (checkAlg == checkBaj && i == 1) { cout << "remis"; } } } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #include <iostream> using namespace std; int check(int a, int tab[18]) { int counter = 0; for (int i = 0; i < 18; i++) { if (tab[i] == a) { counter++; } } return counter; } int main() { int Alg[18], Baj[18]; int sumAlg = 0, sumBaj = 0; int checkAlg, checkBaj; for (int i = 0; i < 18; i++) { cin >> Alg[i]; sumAlg = sumAlg + Alg[i]; } for (int i = 0; i < 18; i++) { cin >> Baj[i]; sumBaj = sumBaj + Baj[i]; } if (sumAlg > sumBaj) { cout << "Algosia"; } else if (sumAlg < sumBaj) { cout << "Bajtek"; } else if (sumAlg == sumBaj) { for (int i = 9; i > 0; i--) { checkAlg = check(i, Alg); checkBaj = check(i, Baj); if (checkAlg > checkBaj) { cout << "Algosia"; break; } else if (checkAlg < checkBaj) { cout << "Bajtek"; break; } else if (checkAlg == checkBaj && i == 1) { cout << "remis"; } } } return 0; } |