1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include <iostream.h>
#include <conio.h>
void tri_iteratif(int tableau[ ], int grosseur) {
int temp, i, j;
for (i = 0; i < grosseur; i++)
for (j = 0; j < grosseur; j++)
if (tableau[i] < tableau[j]) {
temp = tableau[i];
tableau[i] = tableau[j];
tableau[j] = temp;
}
}
main() {
int valeurs[10], i;
for (i = 0; i < 10; i++)
valeurs[i] = rand() % 1000;
tri_iteratif(valeurs, 10);
for (i = 0; i < 10; i++)
cout << valeurs[i] << " ";
cout <<""<<endl;
cout << "Decroissant: " <<endl;
cout <<""<<endl;
getch();
return 0;
} |
Partager