TP4 E3
This commit is contained in:
parent
b2da77824f
commit
6c2b2b8dcd
1
TP4/E1.c
1
TP4/E1.c
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
int T[] = {12, 23, 34, 45, 56, 67, 78, 89, 90};
|
int T[] = {12, 23, 34, 45, 56, 67, 78, 89, 90};
|
||||||
|
|
1
TP4/E2.c
1
TP4/E2.c
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
int X = 0, n, *P1, *P2;
|
int X = 0, n, *P1, *P2;
|
||||||
|
|
24
TP4/E3.c
Normal file
24
TP4/E3.c
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/* Inversion de tableau */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
|
int T[] = {12, 23, 34, 45, 56, 67, 78, 89, 90};
|
||||||
|
int *P1, *P2, temp, n = sizeof(T)/sizeof(int);
|
||||||
|
|
||||||
|
P2 = T + n - 1;
|
||||||
|
for (P1 = T; P1 < T + n/2; P1++, P2--) {
|
||||||
|
temp = *P1;
|
||||||
|
*P1 = *P2;
|
||||||
|
*P2 = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (P1 = T; P1 < T + n; P1++) {
|
||||||
|
printf("%d, ", *P1);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in a new issue