Bubble Sort

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <stdio.

h>
#include <stdlib.h>
int main()
{
int a[100], i, n, j, elem;
printf("n="); scanf("%d", &n);
for(i=0;i<n;i++)
{
printf("a[%d]=", i);
scanf("%d", &a[i]);
}
for(i=n-1;i>0;i--)
for(j=1;j<=i;j++)
if(a[j-1]>a[j])
{
elem=a[j-1];
a[j-1]=a[j];
a[j]=elem;
}
printf("Multimea numerelor ordonate este: {");
for(i=0;i<n;i++)
printf("%d ", a[i]);
printf("}");
return 0;
}

You might also like