12 Octobre
This commit is contained in:
parent
965589da20
commit
d6fccd8f37
Binary file not shown.
25
DEV1.1/TP06:Tableaux/filtre.c
Normal file
25
DEV1.1/TP06:Tableaux/filtre.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
int tab[10];
|
||||
srand(time(NULL));
|
||||
for (i=0;i<10;i++){
|
||||
tab[i]=((rand()%101)-50);
|
||||
} printf("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
for (i=0;i<10;i++){
|
||||
printf("| %3d ",tab[i]);
|
||||
} printf("|\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
printf("Voici le tableau sans les valeurs negatives:\n");
|
||||
printf("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
for (i=0;i<10;i++){
|
||||
if (tab[i]>0){
|
||||
printf("| %3d ",tab[i]);
|
||||
} else{
|
||||
printf("| ");
|
||||
}
|
||||
} printf("|\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
return 0;
|
||||
}
|
22
DEV1.1/TP06:Tableaux/maximum.c
Normal file
22
DEV1.1/TP06:Tableaux/maximum.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
int max;
|
||||
int tab[10];
|
||||
srand(time(NULL));
|
||||
for (i=0;i<10;i++){
|
||||
tab[i]=((rand()%101)-50);
|
||||
} printf("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
max=tab[0];
|
||||
for (i=0;i<10;i++){
|
||||
printf("| %3d ",tab[i]);
|
||||
if (max<tab[i]){
|
||||
max=tab[i];
|
||||
}
|
||||
} printf("|\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
printf("Le plus gans element du tableaux est %d\n",max);
|
||||
return 0;
|
||||
}
|
29
DEV1.1/TP06:Tableaux/miroir.c
Normal file
29
DEV1.1/TP06:Tableaux/miroir.c
Normal file
@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
int tab[10];
|
||||
srand(time(NULL));
|
||||
for (i=0;i<10;i++){
|
||||
tab[i]=((rand()%101)-50);
|
||||
} printf("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
for (i=0;i<10;i++){
|
||||
printf("| %3d ",tab[i]);
|
||||
} printf("|\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
printf("Voici le tableaux inverse:\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
i=9;
|
||||
for(j=0;j<5;j++){
|
||||
k=tab[j];
|
||||
tab[j]=tab[i];
|
||||
tab[i]=k;
|
||||
i--;
|
||||
}
|
||||
for (i=0;i<10;i++){
|
||||
printf("| %3d ",tab[i]);
|
||||
} printf("|\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
return 0;
|
||||
}
|
27
DEV1.1/TP06:Tableaux/recherche.c
Normal file
27
DEV1.1/TP06:Tableaux/recherche.c
Normal file
@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
int n;
|
||||
int m;
|
||||
int min=-1;
|
||||
int tab[10];
|
||||
srand(time(NULL));
|
||||
for (i=0;i<10;i++){
|
||||
tab[i]=((rand()%101)-50);
|
||||
} printf("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
for (i=0;i<10;i++){
|
||||
printf("| %3d ",tab[i]);
|
||||
} printf("|\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
printf("Veuillez saisir un entier : ");
|
||||
scanf("%d",&m);
|
||||
for (i=0;i<10;i++){
|
||||
if (tab[i]==m){
|
||||
min = i;
|
||||
break;
|
||||
}
|
||||
} printf("Le plus petit indice ou se trouve votre entier est %d .\n",min);
|
||||
return 0;
|
||||
}
|
16
DEV1.1/TP06:Tableaux/remplissage.c
Normal file
16
DEV1.1/TP06:Tableaux/remplissage.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
int tab[10];
|
||||
srand(time(NULL));
|
||||
for (i=0;i<10;i++){
|
||||
tab[i]=((rand()%101)-50);
|
||||
} printf("+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
for (i=0;i<10;i++){
|
||||
printf("| %3d ",tab[i]);
|
||||
} printf("|\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+\n");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user