This repository has been archived on 2019-08-08. You can view files and clone it, but cannot push or open issues/pull-requests.
s6-pa-tp/TP10/exo1.c

31 рядки
471 B
C

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

#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]);
}
}