-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFIFA_OVR.cpp
82 lines (68 loc) · 1.79 KB
/
FIFA_OVR.cpp
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include<bits/stdc++.h>
using namespace std;
class Player
{
public:
string name;
int ovr;
string position;
string status;
void addPlayer(string name, int ovr, string position, string status){
this->name = name;
this->ovr = ovr;
this->position = position;
this->status = status;
}
void display(){
cout<<this->name<<" "<<this->ovr<<" "<<this->position<<" "<<this->status<<endl;
}
};
bool comp(Player a, Player b){
return a.ovr > b.ovr;
}
int main()
{
freopen("OVR.txt", "r", stdin);
Player players[40];
string name,position,status;
int ovr,n=0,playerCount = 11;
while(cin>>name>>ovr>>position>>status){
players[n++].addPlayer(name,ovr,position,status);
}
sort(players, players+n, comp);
int gk=1, defenders = 4, cdm = 1, cm = 2, cam = 1, forward = 2;
for (int i = 0; i < n && playerCount>0 ; ++i)
{
if (players[i].status == "Fit")
{
if (players[i].position == "GK" && gk>0)
{
players[i].display();
playerCount--;
gk--;
}else if (players[i].position == "CDM" && cdm > 0)
{
players[i].display();
playerCount--;
cdm--;
}else if(players[i].position == "CM" && cm > 0)
{
players[i].display();
playerCount--;
cm--;
}else if(players[i].position == "CAM" && cam > 0){
playerCount--;
cam--;
players[i].display();
}else if((players[i].position == "LW" || players[i].position == "RW" || players[i].position == "ST") && forward >0){
players[i].display();
forward--;
playerCount--;
}else if((players[i].position == "LB" || players[i].position == "CB" || players[i].position == "RB") && defenders >0){
players[i].display();
defenders--;
playerCount--;
}
}
}
}