▲ 3 r/C_Programming
hello, i'm learning C and i made this function who sort a list, i'm pretty sure it's not the best what could i improve ?
void class_tab(int tab[], int taille)
{
int i =0, n = 0, greater=0;
int old_tab[100] = {0};
copier_tab(tab, old_tab, taille); // copy tab in old_tab
int new_tab[100] = {0};
do
{
greater = 0;
for ( i=0;i < taille; i++)
{
if (old_tab[i] > greater)
{
greater = old_tab[i];
}
}
for ( i=0;i < taille; i++)
{
if (old_tab[i] == greater)
{
new_tab[n] = old_tab[i];
old_tab[i] = 0;
n++;
}
}
} while ( n <= taille);
copier_tab(new_tab, tab, 10);
}
u/Icy-Manufacturer496 — 8 days ago