Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int csapat_osszpont(const vector<jatekos> &x){
- int y = 0;
- for(int i=0;i<(int)x.size();++i){
- y = y + x[i].pont;
- }
- return y;
- }
- void csapat_beoszt(vector<vector<jatekos> > &teams, const vector<jatekos> &temp, int &red_ossz, int &blue_ossz, const int &darab, const string &kaszt2){
- int red_count = 0, blue_count = 0, i=0;
- while(i<(int)temp.size()){
- if(temp[i].kaszt.compare(kaszt2) == 0){
- if ((red_ossz <= blue_ossz or blue_count == darab) and red_count < darab){
- teams[0].push_back(temp[i]);
- red_ossz = red_ossz + temp[i].pont;
- ++red_count;
- }else if ((red_ossz > blue_ossz or red_count == darab)and blue_count < darab){
- teams[1].push_back(temp[i]);
- blue_ossz = blue_ossz + temp[i].pont;
- ++blue_count;
- }
- }
- ++i;
- }
- }
- vector<jatekos> rendez(vector<jatekos> &temp){
- vector<jatekos> elso = temp, masodik;
- masodik.resize(0);
- jatekos max = elso[0];
- int i=0;
- while(elso.size()>0){
- i = 0;
- max = elso[0];
- for(int j=1;j<(int)elso.size();++j){
- if(max.pont <= elso[j].pont){
- max = elso[j];
- i = j;
- }
- }
- masodik.push_back(max);
- elso.erase(elso.begin() + i);
- }
- temp = masodik;
- return temp;
- }
- vector<jatekos> kaszt_beoszt(const vector<jatekos> &t, const string &str){
- cin.clear();
- cin.sync();
- jatekos x;
- vector<jatekos> temp;
- vector<string> v;
- string strg;
- bool l = false, m = true;
- do{
- cout << str << ": ";
- getline(cin,strg);
- v = split(strg);
- l = false;
- m = true;
- for(int i=0;i<(int)v.size();++i){
- for(int j=0;j<(int)t.size();++j){
- l = l or (v[i] == t[j].nev);
- }
- m = m and l;
- l = false;
- }
- if(not m){
- cout << "Egy jatekos neve hibasan lett megadva! Probald ujra!" << endl;
- }
- }while(not m);
- for(int i=0;i<(int)v.size();++i){
- x.nev = v[i];
- x.kaszt = str;
- for(int j=0;j<(int)t.size();++j){
- if(x.nev == t[j].nev) x.pont = t[j].pont;
- }
- temp.push_back(x);
- }
- cout << endl;
- return temp;
- }
Advertisement
Add Comment
Please, Sign In to add comment