/* To programma pairnei ws orismata: ton arithmo twn dosolhpsiwn N ton arithmo twn praksewn ana dosolhpsia M ton arithmo twn antikeimenwn O ton bathmo polyplexias k Dhladh to programma trexei ws ekhs: ./a.out N M O k Gia na ginei compile xrhsimopoioyme to flag -lm, dhladh: gcc -lm schedule.c */ #include #include #include typedef struct transaction { int *objects; int *action; }transaction; typedef struct schedule { int trans1; int *acts; }schedule; typedef struct node { int tn; int ac; struct node *next; }node; int round(float x) { if((ceil(x)-x)>=0.5) return(floor(x)); else return(ceil(x)); } int Uniform(int a, int b) { float r; r=drand48(); r=a+(b-a)*r; return(round(r)); } int actions(void) { float u; u=drand48(); if(u<=0.8) return(0); else return(1); } int object(int O) { float u; int i; float s,j; u=drand48(); s=O; for(i=1;i<=O;i++) { j=i; if(unext=NULL; new->tn=sch[i].trans1; new->ac=trans[sch[i].trans1].action[j]; if(top[trans[sch[i].trans1].objects[j]]==NULL) top[trans[sch[i].trans1].objects[j]]=new; else { temp=top[trans[sch[i].trans1].objects[j]]; while(temp->next!=NULL) temp=temp->next; temp->next=new; } } } counter[sch[i].trans1]++; } for(i=0;inext; while(temp!=NULL) { if(current->tn!=temp->tn) if((current->ac==1)||(temp->ac==1)) { adjacent[current->tn][temp->tn]=1; c[current->tn][temp->tn]=1; } temp=temp->next; } current=current->next; } } printf("\n"); for(l=1;l