diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-07-26 23:17:36 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-07-26 23:17:36 +0200 |
| commit | 8ec5431354bdb582455e8c32758098c5a0fdada2 (patch) | |
| tree | 480c68814f822439850029df0e0249a2cafb8177 /exam_final/subjects/9-0-sort_list | |
| parent | 475449dd4b1f3308bac6f72c34d87812216a0738 (diff) | |
| download | piscine-8ec5431354bdb582455e8c32758098c5a0fdada2.tar.gz piscine-8ec5431354bdb582455e8c32758098c5a0fdada2.tar.bz2 piscine-8ec5431354bdb582455e8c32758098c5a0fdada2.zip | |
exam final
Diffstat (limited to 'exam_final/subjects/9-0-sort_list')
| -rw-r--r-- | exam_final/subjects/9-0-sort_list/list.h | 19 | ||||
| -rw-r--r-- | exam_final/subjects/9-0-sort_list/subject.en.txt | 32 | ||||
| -rw-r--r-- | exam_final/subjects/9-0-sort_list/subject.fr.txt | 32 |
3 files changed, 83 insertions, 0 deletions
diff --git a/exam_final/subjects/9-0-sort_list/list.h b/exam_final/subjects/9-0-sort_list/list.h new file mode 100644 index 0000000..34a3677 --- /dev/null +++ b/exam_final/subjects/9-0-sort_list/list.h @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* list.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: zaz <zaz@staff.42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2014/02/27 13:14:10 by zaz #+# #+# */ +/* Updated: 2014/02/27 13:15:29 by zaz ### ########.fr */ +/* */ +/* ************************************************************************** */ + +typedef struct s_list t_list; + +struct s_list +{ + int data; + t_list *next; +}; diff --git a/exam_final/subjects/9-0-sort_list/subject.en.txt b/exam_final/subjects/9-0-sort_list/subject.en.txt new file mode 100644 index 0000000..13d9a15 --- /dev/null +++ b/exam_final/subjects/9-0-sort_list/subject.en.txt @@ -0,0 +1,32 @@ +Assignment name : sort_list +Expected files : sort_list.c +Allowed functions: +-------------------------------------------------------------------------------- + +Write the following function: + +t_list *sort_list(t_list* lst, int (*cmp)(int, int)); + +This function must sort the list given as a parameter, using the function +pointer cmp to select the order to apply, and returns a pointer to the +first element of the sorted list. + +Duplications must remain. + +Inputs will always be consistent. + +You must use the type t_list described in the file list.h +that is provided to you. You must include that file +(#include "list.h"), but you must not turn it in. We will use our own +to compile your assignment. + +Functions passed as cmp will always return a value different from +0 if a and b are in the right order, 0 otherwise. + +For example, the following function used as cmp will sort the list +in ascending order: + +int ascending(int a, int b) +{ + return (a <= b); +} diff --git a/exam_final/subjects/9-0-sort_list/subject.fr.txt b/exam_final/subjects/9-0-sort_list/subject.fr.txt new file mode 100644 index 0000000..235c66c --- /dev/null +++ b/exam_final/subjects/9-0-sort_list/subject.fr.txt @@ -0,0 +1,32 @@ +Assignment name : sort_list +Expected files : sort_list.c +Allowed functions: +-------------------------------------------------------------------------------- + +Écrire la fonction suivante: + +t_list *sort_list(t_list* lst, int (*cmp)(int, int)); + +Cette fonction doit trier la liste passée en premier paramètre, en utilisant le +pointeur sur fonction cmp pour déterminer l'ordre à appliquer, et +renvoyer un pointeur vers le premier élément de la liste triée. + +Les doublons doivent être préservés. + +Les entrées seront toujours cohérentes. + +Vous devez utiliser le type t_list décrit dans le fichier list.h qui vous est +fourni. Vous devrez inclure (#include "list.h") ce fichier, mais ne pas le +rendre. Nous utiliserons le notre pour compiler votre exercice. + +Les fonctions passées en tant que cmp renverront toujours une valeur +différente de 0 si a et b sont dans le bon ordre, +dans le cas contraire elles renverront 0. + +Par exemple, la fonction suivante utilisée en tant que cmp devra +permettre de trier la liste par ordre croissant: + +int croissant(int a, int b) +{ + return (a <= b); +} |
