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 32 33 34 35 36 37 38 39 40
| //---------------------------------------------------------------------------
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
void tri_iteratif(char *tableau[], int taille)
{
char temp[20];
int i, j;
for (i = 0; i < taille; i++)
for (j = 0; j < taille; j++)
if (strcmp(tableau[i], tableau[j]) < 0)
{
strcpy(temp,tableau[i]);
strcpy(tableau[i],tableau[j]);
strcpy(tableau[j] , temp );
}
}
int main()
{
char tb[2][20];
int i;
char mot[20];
for(i=0;i<2;i++) {
printf( "\n entrer un mot :");
scanf("%s",mot);
strcpy(tb[i],mot);
}
tri_iteratif(&tb,2);
for (i = 0; i < 2; i++)
printf("\n%s ", tb[i]);
getch();
return 0;
} |
Partager