APL1.1
APL1.2
FUn
TP01
TP02
TP03
TP04
TP05
TP06
arc_en_ciel.c
circulation.c
graph_sup.c
graph_sup.h
maximum.c
selection.c
TP07
TP08
TP09
TP10
TP11
APL2.1
DEV 2.2
DEV 2.3
DEV 3.1
DEV 3.2
DEV 3.4
Fun
HTML
Révisions
graphsup
.gitignore
README.md
56 lines
896 B
C
56 lines
896 B
C
|
#include<stdio.h>
|
||
|
#include<stdlib.h>
|
||
|
#include<time.h>
|
||
|
|
||
|
struct maillon_s {
|
||
|
unsigned short valeur;
|
||
|
struct maillon_s* suivant;
|
||
|
};
|
||
|
|
||
|
typedef struct maillon_s maillon;
|
||
|
typedef maillon* liste;
|
||
|
|
||
|
void list(liste l) {
|
||
|
maillon* m = l;
|
||
|
while (m != NULL) {
|
||
|
printf("%3hu ", m->valeur);
|
||
|
m = m->suivant;
|
||
|
}
|
||
|
puts("");
|
||
|
}
|
||
|
|
||
|
unsigned short max(liste l) {
|
||
|
maillon* m = l;
|
||
|
unsigned short max = 0;
|
||
|
|
||
|
while (m != NULL) {
|
||
|
if (m->valeur > max) max = m->valeur;
|
||
|
m = m->suivant;
|
||
|
}
|
||
|
|
||
|
return max;
|
||
|
}
|
||
|
|
||
|
int main(int argc, char * argv[]) {
|
||
|
liste l;
|
||
|
maillon* last_m = NULL;
|
||
|
|
||
|
srand(time(NULL));
|
||
|
for (int i = 0; i < 10; i++) {
|
||
|
srand(rand());
|
||
|
unsigned short random = rand() % (999-111) + 111;
|
||
|
maillon* new_m = malloc(sizeof(maillon));
|
||
|
new_m->valeur = random;
|
||
|
|
||
|
if (last_m != NULL) new_m->suivant = last_m;
|
||
|
last_m = new_m;
|
||
|
}
|
||
|
|
||
|
l = last_m;
|
||
|
|
||
|
list(l);
|
||
|
printf("%3hu\n", max(l));
|
||
|
return EXIT_SUCCESS;
|
||
|
}
|
||
|
|