#include #include #include #include #include #include class Proiect; //**********CLASA ACTIVITATE****************************************** class Activitate { public: char cod;//codul activitatii char den[50];//denumirea activitatii char *cond;//vector de coduri activitati direct precedente int dur;//durata activitatii int nr_c;//numar de conditionari(dimensiunea vectorului) int tmi;//timp minim de incepere int tmt;//timp minim de terminare int tMi;//timp maxim de incepere int tMt;//timp maxim de terminare Activitate(); void operator =(Activitate &);//operator de atribuire friend class Proiect; friend istream& operator>> (istream&, Activitate&);//intrare obiect Activitate friend ostream& operator<< (ostream&, Activitate);//iesire obiect Activitate }; void Activitate::operator= (Activitate& a) { cod=a.cod; strcpy(den,a.den); dur=a.dur; nr_c=a.nr_c; cond=new char[a.nr_c+2]; for(int i=1;i> (istream &intr,Activitate &a) { cout<<"\nCodul activitatii: ";intr>>a.cod; cout<<"Denumire activitate: ";intr>>a.den; cout<<"Numar de coduri activitati direct precedente: ";intr>>a.nr_c; if(a.nr_c!=0) { a.cond=new char[a.nr_c+1]; for(int i=1;i>a.cond[i]; } } int vb=0; while(vb) { cout<<"Durata activitatii: ";intr>>a.dur; if(a.dur<0) vb=1; } return intr; } ostream& operator<< (ostream &ies, Activitate a) { cout<<"\nCodul activitatii: ";ies<>(ifstream& , Proiect& );//citire Proiect din fisier void print();//afisare timp minim/maxim de incepere/terminare void drum();//determinarea drumului critic si a duratei minime a proiectului int isConditionatDe(char ,char );//test de conditionare void gantt();//afisarea graficului Gantt la termen minim de incepere }; Proiect::Proiect() { nr_act=0; a=new (bool*); a[0]=new bool; act=new Activitate; act[0].cod=' '; act[0].nr_c=0; act[0].dur=0; act[0].tmi=0; act[0].tmt=0; act[0].tMi=0; act[0].tMt=0; strcpy(act[0].den,"nou"); } //introducere vector de activitati void Proiect::GetVect(int n) { act=new Activitate[n+1]; for(int i=1;i>act[i]; } //initializare matrice de precedenta pentru nr activitati; //matricea va avea dimensiunile nr*nr void Proiect::SetMatr(int n) { a=new bool *[n+1]; for(int i=1;iact[i].tmi) { act[i].tmi=act[j].tmt; act[i].tmt=act[i].tmi+act[i].dur; } } } int Proiect::min(int a,int b) { if(aMax_tmt) Max_tmt=act[i].tmt; for(int s=1;s0;s--) for(int d=1;ddMin) dMin=act[i].tmt; cout<"; } } //test de conditionalitate int Proiect::isConditionatDe(char c1,char c2) { int k; for(int i=1;idMin) dMin=act[i].tmi; int dMax=0; for(i=1;idMin) dMax=act[i].tMt; int n=nr_act; int *minim; minim=new int[n+1]; for(i=1;i1) { for(int j=2;j1;j--) if(minim[j]==dMin) n=n-1; } n=n+1; for(int j=n;j>0;j--) { for(i=1;i> (ifstream& intr, Proiect& p) { intr>>p.nr_act; if(p.nr_act!=0) { p.act=new Activitate[p.nr_act+1]; for(int i=1;i>p.act[i].cod; intr>>p.act[i].den; intr>>p.act[i].nr_c; intr>>p.act[i].dur; p.act[i].cond=new char[p.act[i].nr_c+1]; for(int j=1;j>p.act[i].cond[j]; intr>>p.act[i].tMi; intr>>p.act[i].tmi; intr>>p.act[i].tMt; intr>>p.act[i].tmt; } p.SetMatr(p.nr_act); p.TimpMin(); p.TimpMax(); } return intr; } //scriere proiect in fisier ofstream& operator<< (ofstream& ies, Proiect& p) { ies<9.Iesire."; cout<<"\n\n\n\n\n\n"; cout<<"\n Introduceti optiunea: "; cin>>opt; switch(opt) { case 1: { ifstream fisin("fis.dat"); if(!fisin) { cout<<"\nNu exista fisierul"; return; } fisin>>p; for(i=1;i>n; Proiect p(n); ofstream fisout("fis.dat"); if(!fisout) { cout<<"\nNu se poate deschide fisierul"; return; } fisout<>ac; p+ac; cout<<"\nApasati o tasta..."; } break; case 7: { cout<<"\nIntroduceti codul: ";cin>>c; for(i=1;i>c2; for(i=1;i>c1; for(j=1;j