Skip to content
Snippets Groups Projects
Commit 1bb503ba authored by Rabemanantsoa VonaMpiaro's avatar Rabemanantsoa VonaMpiaro
Browse files

Ajoutée des fichiers

parent c8ffa361
No related branches found
No related tags found
No related merge requests found
#include "job_2.h"
#include "job_1 (1).h"
#include "list.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
job_t * new_empty_job(){
job_t * J = calloc ( 1, sizeof (job_t ) );
assert( J );
J->precedence = new_list ( );
J->posteriority = new_list ( );
J->rank = UNDEF;
J->au_plus_tard = UNDEF;
J->au_plus_tot = UNDEF;
J->marge_totale = UNDEF;
J->critique = false;
return J;
}
job_t * new_job(char * title){
job_t * J = new_empty_job ( );
J->title = strdup ( title );
return J;
}
void free_job(job_t ** ptrJ){
assert ( ptrJ && *ptrJ );
if( (*ptrJ)->title ) free ( (*ptrJ)->title );
free ( *ptrJ );
*ptrJ = NULL;
}
void view_job ( job_t * J ) {
printf ( "JOB %s\n\tpreceeded by [", get_job_tilte ( J ) );
for(elmlist_t * E = get_head ( J->precedence ); E; E = get_suc ( E ) ) {
printf ( " %s", get_job_tilte ( get_data ( E ) ) );
}
printf ( " ]\n" );
// if ( !get_numelm ( J->posteriority ) ) printf ( "\t" );
printf ( "\tfollowed by [" );
for(elmlist_t * E = get_head(J->posteriority); E; E = get_suc(E)){
printf(" %s", get_job_tilte(get_data(E)));
}
printf ( " ]\n" );
printf ( "\tiDeg=%d\toDeg=%d\tlife=%2.2lf", J->input_degree, J->output_degree, J->life );
printf ( "\trank=" );
if ( J->rank == UNDEF ) printf ( "U" ); else printf ( "%d", J->rank );
printf ( "\tearly=" );
if(J->au_plus_tot == UNDEF ) printf("U"); else printf ( "%2.2lf",J->au_plus_tot );
printf ( "\tlate=" );
if(J->au_plus_tard == UNDEF ) printf("U"); else printf ( "%2.2lf",J->au_plus_tard );
printf ( "\ttotale= " );
if ( J->marge_totale == UNDEF ) printf("U"); else printf ( "%2.2lf", J->marge_totale );
printf ( "\tcritical= " );
if ( J->critique ) printf("Y\n"); else printf ( "N\n" );
}
char * get_job_tilte(job_t * J) {
assert(J);
return J->title;
}
// Sets the title of the job, freeing the old title if needed.
void set_job_title(job_t * J, char * title) {
assert(J && title);
if(J->title)
free(J->title);
J->title = strdup(title);
}
// Returns the life (duration) of the job.
double get_job_life(job_t * J) {
assert(J);
return J->life;
}
// Sets the life (duration) of the job.
void set_job_life(job_t * J, double life) {
assert(J);
J->life = life;
}
// Returns the input degree (number of precedents) of the job.
int get_job_iDegree(job_t * J) {
assert(J);
return J->input_degree;
}
// Sets the input degree of the job.
void set_job_iDegree(job_t * J, int iDegree) {
assert(J);
J->input_degree = iDegree;
}
// Increments the input degree of the job.
void incr_job_iDegree(job_t * J) {
assert(J);
J->input_degree++;
}
// Decrements the input degree of the job.
void decr_job_iDegree(job_t * J) {
assert(J);
J->input_degree--;
}
\ No newline at end of file
#include "job_1 (1).h"
#include "job_3.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
//TOUS EST CHANGee
int get_job_oDegree(job_t * J) {
assert(J);
return J->output_degree;
}
void set_job_oDegree(job_t * J, int oDegree) {
assert(J);
J->output_degree = oDegree;
}
void incr_job_oDegree(job_t * J) {
assert(J);
J->output_degree++;
}
void decr_job_oDegree(job_t * J) {
assert(J);
J->output_degree--;
}
int get_job_rank(job_t * J) {
assert(J);
return J->rank;
}
void set_rank(job_t * J, int rank) {
assert(J);
J->rank = rank;
}
int titleJobCmp(job_t * J1, job_t * J2) {
assert(J1 && J2);
return strcmp(J1->title, J2->title);
}
int iDegreeJobCmp(job_t * J1, job_t * J2) {
assert(J1 && J2);
return J1->input_degree - J2->input_degree;
}
int oDegreeJobCmp(job_t * J1, job_t * J2) {
assert(J1 && J2);
return J1->output_degree - J2->output_degree;
}
int rangJobCmp(job_t * J1, job_t * J2) {
assert(J1 && J2);
return J1->rank - J2->rank;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment