Ce dépôt a été archivé le 2019-08-08. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
s6-pa-tp/TP10/exo1.c

31 lignes
471 B
C
Brut Lien permanent Annotations Historique

Ce fichier contient des caractères Unicode invisibles.

Ce fichier contient des caractères Unicode invisibles à l'œil nu, mais peuvent être traités différemment par un ordinateur. Si vous pensez que c'est intentionnel, vous pouvez ignorer cet avertissement. Utilisez le bouton Échappe pour les dévoiler.

#include <stdlib.h>
#include <stdio.h>
// 2.1.1
// Signature : int f(int)
int fois_deux(int a) {
return a*2;
}
// 2.1.2
void appliquer_tableau(int f(int), int t[], int size) {
int i;
for (i = 0; i < size; i++) {
t[i] = f(t[i]);
}
}
// 2.1.3
#define SIZE 5
int main() {
int t[SIZE] = {1, 4, 7, 9, 3};
int i;
appliquer_tableau(fois_deux, t, SIZE);
for (i = 0; i < SIZE; i++) {
printf("t[%d] = %d\n", i, t[i]);
}
}