Travaux Pratiques de la matière Programmation Avancée d'IMA 3 (semestre 6).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

31 lines
471B

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. // 2.1.1
  4. // Signature : int f(int)
  5. int fois_deux(int a) {
  6. return a*2;
  7. }
  8. // 2.1.2
  9. void appliquer_tableau(int f(int), int t[], int size) {
  10. int i;
  11. for (i = 0; i < size; i++) {
  12. t[i] = f(t[i]);
  13. }
  14. }
  15. // 2.1.3
  16. #define SIZE 5
  17. int main() {
  18. int t[SIZE] = {1, 4, 7, 9, 3};
  19. int i;
  20. appliquer_tableau(fois_deux, t, SIZE);
  21. for (i = 0; i < SIZE; i++) {
  22. printf("t[%d] = %d\n", i, t[i]);
  23. }
  24. }