2024-10-14 13:54:43 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2024-10-15 12:29:56 +02:00
|
|
|
|
2024-10-14 13:54:43 +02:00
|
|
|
int main (void){
|
|
|
|
int tableau[10];
|
|
|
|
int i;
|
|
|
|
int x;
|
|
|
|
int a;
|
|
|
|
int plus_grand;
|
|
|
|
srand(time(NULL));
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++){
|
|
|
|
tableau[i] = (rand() &101 ) -50 ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (x = 0; x < 10; x++){
|
|
|
|
printf(" | ");
|
|
|
|
printf("%d", tableau[x]);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
for (a = 0; a < 10; a++){
|
|
|
|
if (tableau[a] > plus_grand){
|
|
|
|
plus_grand = tableau[a];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("le plus grand est : ");
|
|
|
|
printf("%d", plus_grand);
|
|
|
|
printf("\n");
|
|
|
|
|
2024-10-15 12:29:56 +02:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
srand(time(NULL));
|
|
|
|
int min = 1; // Valeur minimale pour les nombres aléatoires
|
|
|
|
int max = 100; // Valeur maximale pour les nombres aléatoires
|
|
|
|
int i;
|
|
|
|
int tableau[10];
|
|
|
|
int tableauInverse[10]; // Tableau pour stocker les valeurs inversées
|
|
|
|
|
|
|
|
// Remplir le tableau avec des nombres aléatoires
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
tableau[i] = min + rand() % (max - min + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Afficher le tableau initial
|
|
|
|
printf("+");
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
printf("-----+");
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
printf("|%5d", tableau[i]);
|
|
|
|
}
|
|
|
|
printf("|\n");
|
|
|
|
|
|
|
|
printf("+");
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
printf("-----+");
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
// Inverser l'ordre des valeurs
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
tableauInverse[i] = tableau[9 - i];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Afficher le tableau après inversion
|
|
|
|
printf("\nTableau après inversion:\n");
|
|
|
|
printf("+");
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
printf("-----+");
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
printf("|%5d", tableauInverse[i]);
|
|
|
|
}
|
|
|
|
printf("|\n");
|
|
|
|
|
|
|
|
printf("+");
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
printf("-----+");
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
2024-10-14 13:54:43 +02:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|