This repository has been archived on 2019-08-09. You can view files and clone it, but cannot push or open issues or pull requests.
s4-c/TP2/E4.c

40 lines
725 B
C
Raw Normal View History

2016-02-24 11:05:25 +01:00
/* Tableau des différences */
#include <stdio.h>
#define N 10
void soustraire(int A[N], int R[N], int n) {
int i;
for (i = 0; i < n-1; i++) {
R[i] = A[i+1] - A[i];
}
}
void afficherTableau(int A[N], int n) {
int i;
for (i = 0; i < n; i++) {
printf("%11i ", A[i]);
}
printf("\n");
}
int main() {
int X[N] = {2,8,-3,5,9,-4,-2,0,1,16};
int DX[N][N];
int i;
2016-03-09 08:28:07 +01:00
printf("-- X ");
2016-02-24 11:05:25 +01:00
afficherTableau(X, N);
soustraire(X, DX[0], N);
2016-03-09 08:28:07 +01:00
printf("-- D1X");
2016-02-24 11:05:25 +01:00
afficherTableau(DX[0], N-1);
for (i = 0; i < N-1; i++) {
soustraire(DX[i], DX[i+1], N-i);
printf("-- D%dX", i+1);
afficherTableau(DX[i], N-i-1);
}
return 0;
}