Pb tri a bulle
Me--and--Me
Messages postés
76
Statut
Membre
-
Me--and--Me Messages postés 76 Statut Membre -
Me--and--Me Messages postés 76 Statut Membre -
Bonsoir,
j'essaye de compiler ce programme qui est le tri a bulles en c , mais j'ai constament le resultat qui tourne au rond :(
Pouvez-vous m'aider svp. merci d'avance:
voici mon pg :
# include<stdlib.h>
#include<stdio.h>
// Saisie de tablaeu d'entiers
#define n 5
int tab[n]={4,2,3,5,1};
// Affichage du tableau
void affiche_tab ()
{ int j;
for(j=0;j<n;j++)
{ printf("\t\ttab[%d]=%d\n\t\t", j,tab[j]); }
}
// Tri à bulles
void tri_a_bulles ()
{ int c=n , k;
int l=0; // c est le compteur
//while (c>0)
// { l=0;
while (l<c)
{ if(tab[l]>tab[c+1])
k=tab[l+1];
tab[l+1]=tab[l];
tab[l]=k;
printf("Voici le tableau triée %d\n\t\t",tab[l]);
l++;} c--;
}
int main ()
{
affiche_tab();
tri_a_bulles();
}
j'essaye de compiler ce programme qui est le tri a bulles en c , mais j'ai constament le resultat qui tourne au rond :(
Pouvez-vous m'aider svp. merci d'avance:
voici mon pg :
# include<stdlib.h>
#include<stdio.h>
// Saisie de tablaeu d'entiers
#define n 5
int tab[n]={4,2,3,5,1};
// Affichage du tableau
void affiche_tab ()
{ int j;
for(j=0;j<n;j++)
{ printf("\t\ttab[%d]=%d\n\t\t", j,tab[j]); }
}
// Tri à bulles
void tri_a_bulles ()
{ int c=n , k;
int l=0; // c est le compteur
//while (c>0)
// { l=0;
while (l<c)
{ if(tab[l]>tab[c+1])
k=tab[l+1];
tab[l+1]=tab[l];
tab[l]=k;
printf("Voici le tableau triée %d\n\t\t",tab[l]);
l++;} c--;
}
int main ()
{
affiche_tab();
tri_a_bulles();
}
A voir également:
- Pb tri a bulle
- Comment faire un tri personnalisé sur excel - Guide
- Logiciel tri photo - Guide
- Whatsapp couleur bulle - Accueil - Messagerie instantanée
- Bulle sur contact sms - Forum Xiaomi
- Video bulle whatsapp - Accueil - Messagerie instantanée