Skip to content
Extraits de code Groupes Projets
Valider 0f66248e rédigé par Samuh's avatar Samuh
Parcourir les fichiers

Début TP4

parent d4a1970e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -2,7 +2,7 @@ CC = gcc
OPTIONS = -Wall -Wextra -O9
MATH = -lm
EXECUTABLE = TP1 TP2 TP3
EXECUTABLE = TP1 TP2 TP3 TP4
all: $(EXECUTABLE)
......@@ -23,6 +23,8 @@ TP2: TP2.o struct_tp2.o
TP3: TP3.o
TP4: TP4.o
TP1.o: implems.c
......
#include "./implems.c"
#include <stdio.h>
#include <stdlib.h>
// génère un entier aléatoire entre min et max inclue
int randint_from(int min, int max)
{
int range = (max - min);
return min + (rand() % (range + 1));
}
void Fisher_Yates(int *tab, int size) {
int tmp;
int rdm;
for (int i = size-1; i > 0; i--)
{
rdm = randint_from(0, i);
tmp = tab[i];
tab[i] = tab[rdm];
tab[rdm] = tmp;
}
}
int main(int argc, char **argv) {
if (argc < 2) {
printf("un argument est attendu\n");
return 1;
}
adjlist *g;
time_t t1, t2, t3;
// PARSING
t1=time(NULL);
printf("Reading edgelist from file %s\n",argv[1]);
g=al_readedgelist(argv[1]);
t3 = time(NULL);
// printf("- edge list time = %ldh%ldm%lds\n",(t3-t1)/3600,((t3-t1)%3600)/60,((t3-t1)%60));
printf("- edge list time = %I64dh%I64dm%I64ds\n",(t3-t1)/3600,((t3-t1)%3600)/60,((t3-t1)%60));
printf("Number of nodes: %lu\n",g->n);
printf("Number of edges: %lu\n",g->e);
printf("Building the adjacency list\n");
mkadjlist(g);
t2=time(NULL);
// printf("- Overall time = %ldh%ldm%lds\n",(t2-t1)/3600,((t2-t1)%3600)/60,((t2-t1)%60));
printf("- Overall time = %I64dh%I64dm%I64ds\n",(t2-t1)/3600,((t2-t1)%3600)/60,((t2-t1)%60));
unsigned long a = 1;
printf("%I64i %I64i %I64i %i %li\n", sizeof(int), sizeof(unsigned long), sizeof(unsigned long long), RAND_MAX, a);
free_adjlist(g);
return 0;
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter