Witam. Proszę o ocenę sortowanie bąbelkowego w moim wykonaniu. Czy jest w nim coś rażącego, wymagającego zmiany? Za dużo kodu etc?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n, i, j,m;
int temp;
printf("Ile elementow chcesz wprowadzic?\n");
scanf("%d",&n);
int tab[n];
printf("Wprowadz elementy: \n");
for(i=0; i<n; i++)
scanf("%d",&tab[i]);
for(i=1; i<n; i++)
{
for(j=0; j<n; j++)
{
if(tab[j]>tab[j+1])
{
temp=tab[j+1];
tab[j+1]=tab[j];
tab[j]=temp;
}
}
}
for(m=0; m<n; m++)
printf("%d ",tab[m]);
return 0;
}