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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>

using namespace std;

void enter(int* scored_point){
    for(int i = 0; i < 18; i++){
    int random = rand() % 11;
    scored_point[i] = random;
    cout << random << " ";
    }
    cout << "\n";
}

string winner(int* contestant_one, int* contestant_two){
    int total_points_one = 0, total_points_two = 0;
    
    for(int i = 0; i < 18; i++){
        total_points_one += contestant_one[i];
        total_points_two += contestant_two[i];
    }
    
    if(total_points_one > total_points_two)
        return "Algosia";
    else if(total_points_one < total_points_two)
        return "Bajtek";
    else{
        int repeated_point_totals_one = 0, repeated_point_totals_two = 0, search_point = 10;
        
        do{
            
            repeated_point_totals_one = repeated_point_totals_two = 0;
            
            for(int i = 0; i < 18; i++){
                
                if(contestant_one[i] == search_point)
                    repeated_point_totals_one++;
                    
                if(contestant_two[i] == search_point)
                    repeated_point_totals_two++;
                    
            }
            
            search_point--;
            
        }while(repeated_point_totals_one == repeated_point_totals_two && search_point != 0);
        
        if(repeated_point_totals_one > repeated_point_totals_two)
            return "Algosia";
        else if(repeated_point_totals_one < repeated_point_totals_two)
            return "Bajtek";
        else
            return "remis";
    }
}

int main()
{
    int 
    scored_point_Algosia[18], scored_point_Bajtek[18];
    srand(time(NULL));
    enter(scored_point_Algosia);
    enter(scored_point_Bajtek);
    cout << winner(scored_point_Algosia, scored_point_Bajtek);
}