posto la prima parte del codice... magari vedete cose che io non vedo
codice:
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "dllist.h"

using namespace std;

#define NUM 5
#define TIME_UNIT 15

class Ore
{
	public:
	char hh;
	char mm;

	Ore(){hh = mm = 0;}
	void stampa()
	{
		cout.setf(ios::right);
		cout.width(2);
		cout.fill('0');
		cout << (int)hh << ":";
		cout.width(2);
		cout << (int)mm;
		cout.fill(' ');
		cout.unsetf(ios::right);
	}
	int inc(int num = 1)
	{
		for (int i = 0; i < num; i++)
		{
			mm += TIME_UNIT;
			if (mm >= 60)
			{
				hh++;
				mm = 0;
			}
			if (hh >= 24)
			{
				hh = 0;
				return 1;
			}
		}
		return 0;
	}
}ora;

struct Operaio
{
	char matricola[13];
	uint ingresso;
	uint uscita;
	uint ore;
};

void cscr();
void tableRow();
void tableHead();
void tableEntry(const char *fld1, const char *fld2, const char* fld3, int fld4);
void pauseSec(int n = 1);

int main()
{
	srand(time(NULL));
	int num = 0;
	Operaio tmpO, nullO = {"",0,0,0};

	tmpO.ingresso = 0;
	tmpO.uscita = 0;
	tmpO.ore = 0;
	tmpO.matricola[5] = {'\0'};

	DLList<Operaio> dip; // la lista dei dipendenti
	DLList<Operaio> uff; // i dipendenti in ufficio

	FILE *file = NULL;
	if ((file = fopen("tempi.txt", "w")) == NULL)
	{
		cerr << "Impossibile aprire il file\n";
		exit(1);
	}

	// generazione dei dipendenti

	for (int i = 0; i < NUM; i++)
	{
		tmpO.matricola[0] = 'A' + i;
		tmpO.matricola[1] = 'a' + i;
		tmpO.matricola[2] = '\0';
		dip.push_back( tmpO );
		uff.push_back( nullO );
	}

	int ingressi = 0;
	int exit = 0;
	int oreinout = 0;
	ora.inc(30/2);

	while(!exit)
	{
		cscr();
		oreinout++;
		if ((ora.hh >= 8) && (ora.hh <= 9))
		{
			for (int j = 0; j < rand() % 2 + 1; j++)
			while(1) // finche non sono tutti al lavoro
			{
				dip.first();
				uff.first();
				int ran = rand() % NUM;
				for(int i = 0; i < ran; i++, dip++, uff++);
				if (dip.get().matricola[0] != '\0')
				{
					uff.del();
					uff.put(dip.get());
					dip.del();
					dip.put(nullO);
					uff.mod().ingresso = oreinout;
					break;
				}
				dip.first();
				int count = 0;
				for (int i = 0; ((i < dip.getNum()) && (dip.get().matricola[0] == '\0')); i++, dip++, count++);
				// vede quanti sono i dipendenti al lavoro
				if (count == dip.getNum())
					break;
			}
		}
		else if ((ora.hh >= 17) && (ora.hh <= 21))
		{
			for (int j = 0; j < rand() % 2 + 1; j++)
			while(1) // finche non sono tutti a casa :)
			{
				dip.first();
				uff.first();
				int ran = rand() % NUM;
				for(int i = 0; i < ran; i++, dip++, uff++);
				if (uff.get().matricola[0] != '\0')
				{
					//cout << "Spostamento num: " << ran << "\n";
					dip.del();
					dip.put(uff.get());
					uff.del();
					uff.put(nullO);
					dip.mod().uscita = oreinout;
					break;
				}
				uff.first();
				int count = 0;
				for (int i = 0; ((i < uff.getNum()) && (uff.get().matricola[0] == '\0')); i++, uff++, count++);
				// vede quanti sono i dipendenti al lavoro
				if (count == uff.getNum())
					break;
			}
		}
		uff.first();
		for (int i = 0; i < uff.getNum(); i++, uff++)
			if (uff.get().matricola[0] != '\0')
				uff.mod().ore++;

		tableRow();
		tableHead();
		tableRow();
		dip.first();
		uff.first();
		for (int i = 0; i < NUM; i++, dip++, uff++)
			tableEntry(dip.get().matricola, "", uff.get().matricola, uff.get().ore / ( 60 / TIME_UNIT + 1 ) );
		tableRow();
		cout << " - ORE: "; ora.stampa(); cout << " \n";
		exit = ora.inc();
		pauseSec();
	}

	dip.first();
	for (int i = 0; i < NUM; i++, dip++)
		fprintf(file, "%s %d %d %d\n", dip.get().matricola, dip.get().ingresso, dip.get().uscita, dip.get().ore / ( 60 / TIME_UNIT + 1 ) );
	fclose(file);
	return 0;
}

void cscr()
{
#if 1
	cout << "\033[2J\033[1;1H"; // cancella e porta in alto a sin
#elif
	clrscr();
#endif
}


void tableHead()
{
	cout << "|   MATRICOLA   |   MATRICOLA   |  ORE  |\n";
}

void tableRow()
{
	cout << "+---------------+---------------+-------+\n";
}

void tableEntry(const char *fld1, const char *fld2, const char* fld3, int fld4)
{
	cout << "| ";
	cout.setf(ios::left);
	cout.width(14);
	cout << fld1 << "| ";
	cout.width(14);
	cout << fld3 << "| ";
	cout.width(6);
	cout << fld4 << "|\n";
}

void pauseSec(int n)
{
	int now = time(NULL);
	while(now + n != time(NULL));
}
anzi l'ho postato tutto :P

grazie
ciao