このリポジトリは2019-08-08にアーカイブされています。 ファイルの閲覧やリポジトリのクローンは可能ですが、プッシュしたり、イシューやプルリクエストを作成することはできません。
s6-pa-tp/TP10/exo1.c

31 行
471 B
C
Raw パーマリンク Blame 履歴

このファイルには不可視のUnicode文字が含まれています!

このファイルには不可視Unicode文字が含まれており、下に見えているものとは異なる処理が行われる可能性があります。 あなたのユースケースが意図的かつ正当な場合はこの警告を無視して構いません。 不可視文字を表示するにはエスケープボタンを使用します。

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