JimMorrison723

Untitled

Jun 30th, 2011
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.38 KB | None | 0 0
  1. int csapat_osszpont(const vector<jatekos> &x){
  2.     int y = 0;
  3.     for(int i=0;i<(int)x.size();++i){
  4.         y = y + x[i].pont;
  5.     }
  6.     return y;
  7. }
  8.  
  9. void csapat_beoszt(vector<vector<jatekos> > &teams, const vector<jatekos> &temp, int &red_ossz, int &blue_ossz, const int &darab, const string &kaszt2){
  10.     int red_count = 0, blue_count = 0, i=0;
  11.     while(i<(int)temp.size()){
  12.         if(temp[i].kaszt.compare(kaszt2) == 0){
  13.             if ((red_ossz <= blue_ossz or blue_count == darab) and red_count < darab){
  14.                 teams[0].push_back(temp[i]);
  15.                 red_ossz = red_ossz + temp[i].pont;
  16.                 ++red_count;
  17.             }else if ((red_ossz > blue_ossz or red_count == darab)and blue_count < darab){
  18.                 teams[1].push_back(temp[i]);
  19.                 blue_ossz = blue_ossz + temp[i].pont;
  20.                 ++blue_count;
  21.             }
  22.         }
  23.         ++i;
  24.     }
  25. }
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32. vector<jatekos> rendez(vector<jatekos> &temp){
  33.     vector<jatekos> elso = temp, masodik;
  34.     masodik.resize(0);
  35.     jatekos max = elso[0];
  36.     int i=0;
  37.     while(elso.size()>0){
  38.         i = 0;
  39.         max = elso[0];
  40.         for(int j=1;j<(int)elso.size();++j){
  41.             if(max.pont <= elso[j].pont){
  42.                 max = elso[j];
  43.                 i = j;
  44.             }
  45.         }
  46.         masodik.push_back(max);
  47.         elso.erase(elso.begin() + i);
  48.     }
  49.     temp = masodik;
  50.     return temp;
  51. }
  52.  
  53. vector<jatekos> kaszt_beoszt(const vector<jatekos> &t, const string &str){
  54.     cin.clear();
  55.     cin.sync();
  56.  
  57.     jatekos x;
  58.     vector<jatekos> temp;
  59.     vector<string> v;
  60.     string strg;
  61.     bool l = false, m = true;
  62.  
  63.     do{
  64.         cout << str << ": ";
  65.         getline(cin,strg);
  66.         v = split(strg);
  67.         l = false;
  68.         m = true;
  69.         for(int i=0;i<(int)v.size();++i){
  70.             for(int j=0;j<(int)t.size();++j){
  71.                 l = l or (v[i] == t[j].nev);
  72.             }
  73.             m = m and l;
  74.             l = false;
  75.         }
  76.         if(not m){
  77.             cout << "Egy jatekos neve hibasan lett megadva! Probald ujra!" << endl;
  78.         }
  79.     }while(not m);
  80.     for(int i=0;i<(int)v.size();++i){
  81.         x.nev = v[i];
  82.         x.kaszt = str;
  83.         for(int j=0;j<(int)t.size();++j){
  84.             if(x.nev == t[j].nev) x.pont = t[j].pont;
  85.         }
  86.         temp.push_back(x);
  87.     }
  88.     cout << endl;
  89.     return temp;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment