// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>

using namespace std;

const int N = 6;

void init(int *team)
{
   for(int i = 0; i < N; i++)
   {
      team[i] = 0;
   }
}

int count(int *team, int v)
{
   int res = 0;
   for(int i = 0; i < N; i++)
   {
      if(team[i]==v) res++;
   }
   return res;
}

void fill(int *team)
{
   for(int i = 0; i < N; i++)
   {
      if(team[i]==0) team[i] = 2;
   }
}

int main()
{
   string names[N] = { "aa", "bb", "cc", "dd", "ee", "ff" };
   srand(time(NULL));
   int *team = new int[N];
   init(team);
   while(count(team,1)<N/2)
   {
      int ix = (rand() >> 8) % N;
      team[ix] = 1;
   }
   fill(team);
   cout << "Team 1:" << endl;
   for(int i = 0; i < N; i++)
   {
      if(team[i]==1) cout << names[i] << endl;
   }
   cout << "Team 2:" << endl;
   for(int i = 0; i < N; i++)
   {
      if(team[i]==2) cout << names[i] << endl;
   }
   return 0;
}

