Sorting arrays

Pleasae help with this code. The questions asks to sort the numbers in set from minimum to maximum.

[code]
#include <stdio.h>
int a[100];
int n,i,x,j;
int temp;
int main(int argc, char *argv[])
{
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<=n-1;i++)
{
for(j=i+1;j<=n-2;j++)
{ if(a[i]>a[j])
{ temp=a[i];
a[i]=a[j];
a[j]=temp;}
}}
for(i=0;i<n-1;i++)
printf("%d ",a[i]);
printf("%d\n",a[n-1]);
system("pause");


getchar();
return 0;

}
You are attempting a bubble sort.
http://www.cplusplus.com/faq/sequences/sequencing/sort-algorithms/bubble-sort/

Your brace style is messing you up. Put a brace on a line by itself.

Hope this helps.
Topic archived. No new replies allowed.