TP4 E2
Un mix entre ce qui est demandé et ce qui me paraît plus correct.
This commit is contained in:
parent
72d2f70b99
commit
b2da77824f
38
TP4/E2.c
Normal file
38
TP4/E2.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* Retirer les éléments d'un tableau */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int X = 0, n, *P1, *P2;
|
||||
printf("Saississez la taille de la chaîne : ");
|
||||
scanf("%d", &n);
|
||||
int T[n];
|
||||
for (P1 = T; P1 < T+n; P1++) {
|
||||
*P1 = 0;
|
||||
printf("Saississez le caractère à l'indice %d : ", P1-T);
|
||||
scanf("%s", P1);
|
||||
}
|
||||
printf("Saississez la caractère X : ");
|
||||
scanf("%s", &X);
|
||||
|
||||
P2 = T;
|
||||
for (P1 = T; P1 < T+n; P1++) {
|
||||
if (*P1 != X) {
|
||||
*P2 = *P1;
|
||||
P2++;
|
||||
}
|
||||
}
|
||||
*P2 = '\0';
|
||||
|
||||
for (P1 = T; P1 < T+n; P1++) {
|
||||
if (*P1 == '\0') {
|
||||
break;
|
||||
}
|
||||
printf("%s", P1);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
all: $(patsubst %.c,%.exe,$(shell ls *.c))
|
||||
|
||||
%.exe: %.c
|
||||
gcc $< -o $@ -lm
|
||||
gcc -g $< -o $@ -lm
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
|
|
Reference in a new issue