From 73ed29058bc574013b4978b29eb96b3e1c576d16 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Wed, 23 Mar 2016 11:15:58 +0100 Subject: [PATCH] TP4 E4 --- TP4/E4.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 TP4/E4.c diff --git a/TP4/E4.c b/TP4/E4.c new file mode 100644 index 0000000..db52f3f --- /dev/null +++ b/TP4/E4.c @@ -0,0 +1,27 @@ +/* Comparaison de deux tableaux d'entiers */ + +#include +#include + +int main(int argc, char *argv[]) { + + int T1[] = {12, 23, 34, 45, 56, 67, 78, 89, 90}; + int T2[] = {12, 23, 34, 45, 56, 67, 78, 89, 90}; + + + if (sizeof(T1) != sizeof(T2)) { + printf("Les tableaux ne sont pas de la même taille.\n"); + exit(EXIT_SUCCESS); + } + int n = sizeof(T1)/sizeof(int); + int *P1, *P2; + for (P1 = T1, P2 = T2; P1 < T1 + n; P1++, P2++) { + if (*P1 != *P2) { + printf("Les tableaux diffèrent.\n"); + exit(EXIT_SUCCESS); + } + } + printf("Les tableaux sont identiques.\n"); + exit(EXIT_SUCCESS); + return 0; +}