init projet
This commit is contained in:
61
tp2/compare.h
Normal file
61
tp2/compare.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef _COMPARE_H
|
||||
#define _COMPARE_H
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// réel aléatoire dans [0,1]
|
||||
#define RAND01 ((double)random() / RAND_MAX)
|
||||
#define RANDINT(n) (random() % (n))
|
||||
|
||||
/* compare.c */
|
||||
int fcmp_int(const void *x, const void *y);
|
||||
int fcmp_char(const void *x, const void *y);
|
||||
int fcmp_double(const void *x, const void *y);
|
||||
int fcmp_string(const void *x, const void *y);
|
||||
int fcmp_pointx(const void *p, const void *q);
|
||||
|
||||
#define BAR "-" // un tiret
|
||||
#define MAXSTR 7 // taille max d'une string
|
||||
#define xstr(s) str(s) // permet l'expansion d'une macro
|
||||
#define str(s) #s // Ex: scanf("%"xstr(DMAX)"s",buffer);
|
||||
|
||||
typedef int (*fcmp)(const void *, const void *); // type fonction de comparaison
|
||||
|
||||
typedef char *string; // type chaîne de caractères
|
||||
|
||||
typedef struct {
|
||||
double x, y;
|
||||
} point;
|
||||
|
||||
#define NUMTYPES 5
|
||||
|
||||
typedef enum { // pour les switch()
|
||||
INT = 0,
|
||||
CHAR,
|
||||
DOUBLE,
|
||||
STRING,
|
||||
POINT,
|
||||
} type_t;
|
||||
|
||||
// tableau des types pour l'aide
|
||||
extern char *type[];
|
||||
|
||||
// tableau des tailles des types
|
||||
extern int size[];
|
||||
|
||||
// tableau des tailles d'affichage des types
|
||||
extern int psize[];
|
||||
|
||||
// tableau des fonctions de comparaison
|
||||
extern fcmp cmp[];
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user