#include <iostream> #include <algorithm> using namespace std; int a[20], b[20]; int main() { int suma = 0, sumb = 0; for (int i = 0; i < 18; i++) { cin >> a[i]; suma += a[i]; } for (int i = 0; i < 18; i++) { cin >> b[i]; sumb += b[i]; } if (suma != sumb) { if (suma > sumb) { cout << "Algosia" << endl; } else { cout << "Bajtek" << endl; } return 0; } sort(a, a + 18, [](const int x, const int y) {return x > y;}); sort(b, b + 18, [](const int x, const int y) {return x > y;}); for (int i = 0; i < 18; i++) { if (a[i] != b[i]) { if (a[i] > b[i]) { cout << "Algosia" << endl; } else { cout << "Bajtek" << endl; } return 0; } } cout << "remis" << endl; 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 | #include <iostream> #include <algorithm> using namespace std; int a[20], b[20]; int main() { int suma = 0, sumb = 0; for (int i = 0; i < 18; i++) { cin >> a[i]; suma += a[i]; } for (int i = 0; i < 18; i++) { cin >> b[i]; sumb += b[i]; } if (suma != sumb) { if (suma > sumb) { cout << "Algosia" << endl; } else { cout << "Bajtek" << endl; } return 0; } sort(a, a + 18, [](const int x, const int y) {return x > y;}); sort(b, b + 18, [](const int x, const int y) {return x > y;}); for (int i = 0; i < 18; i++) { if (a[i] != b[i]) { if (a[i] > b[i]) { cout << "Algosia" << endl; } else { cout << "Bajtek" << endl; } return 0; } } cout << "remis" << endl; return 0; } |