From 1bb503ba546fc37239d47294a3845182a40a9ac3 Mon Sep 17 00:00:00 2001 From: Rabemanantsoa VonaMpiaro <e45969u@univ-lorraine.fr> Date: Mon, 17 Mar 2025 21:44:56 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=C3=A9e=20des=20fichiers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LES TA DES TACHES/src/job_2.c | 107 ++++++++++++++++++++++++++++++++++ LES TA DES TACHES/src/job_3.c | 56 ++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 LES TA DES TACHES/src/job_2.c create mode 100644 LES TA DES TACHES/src/job_3.c diff --git a/LES TA DES TACHES/src/job_2.c b/LES TA DES TACHES/src/job_2.c new file mode 100644 index 0000000..6f90c4d --- /dev/null +++ b/LES TA DES TACHES/src/job_2.c @@ -0,0 +1,107 @@ +#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 diff --git a/LES TA DES TACHES/src/job_3.c b/LES TA DES TACHES/src/job_3.c new file mode 100644 index 0000000..9d2337a --- /dev/null +++ b/LES TA DES TACHES/src/job_3.c @@ -0,0 +1,56 @@ +#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; +} -- GitLab