#include<cstdio> using namespace std; const char* result2text[3] = { "remis", "Algosia", "Bajtek" }; int count(const int *t, const int val) { int result = 0; for (int i=0; i<18; ++i) result += (t[i] == val); return result; } int main() { int a[18], b[18], result=0, sum_a=0, sum_b=0; for (int i=0; i<18; ++i) { scanf("%d", &a[i]); sum_a += a[i]; } for (int i=0; i<18; ++i) { scanf("%d", &b[i]); sum_b += b[i]; } //printf("sum_a = %d, sum_b = %d\n", sum_a, sum_b); if (sum_a > sum_b) result = 1; else if (sum_b > sum_a) result = 2; for (int score=10; result == 0 && score > 0; --score) { int ca = count(a, score), cb = count(b, score); //printf("ca = %d, cb = %d\n", ca, cb); if (ca > cb) result = 1; if (cb > ca) result = 2; } printf("%s\n", result2text[result]); }
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 | #include<cstdio> using namespace std; const char* result2text[3] = { "remis", "Algosia", "Bajtek" }; int count(const int *t, const int val) { int result = 0; for (int i=0; i<18; ++i) result += (t[i] == val); return result; } int main() { int a[18], b[18], result=0, sum_a=0, sum_b=0; for (int i=0; i<18; ++i) { scanf("%d", &a[i]); sum_a += a[i]; } for (int i=0; i<18; ++i) { scanf("%d", &b[i]); sum_b += b[i]; } //printf("sum_a = %d, sum_b = %d\n", sum_a, sum_b); if (sum_a > sum_b) result = 1; else if (sum_b > sum_a) result = 2; for (int score=10; result == 0 && score > 0; --score) { int ca = count(a, score), cb = count(b, score); //printf("ca = %d, cb = %d\n", ca, cb); if (ca > cb) result = 1; if (cb > ca) result = 2; } printf("%s\n", result2text[result]); } |