It sorts an array, max size of array is 1024 - the max size is given by our teacher.

Code:

#include <iostream>
using namespace std;
int main()
{
int a[1024], n, x, i, j;
cin >> n;
for ( i = 0; i < n; i++ )
{
cin >> x;
a[i] = x;
}
for ( i = 0; i < n; i++ )
{
for ( j = 0; i+j+1 != n; j++ )
{
if ( a[i] > a[i+j+1] )
{
x = a[i];
a[i] = a[i+j+1];
a[i+j+1] = x;
}
}
}
for ( i = 0; i < n; i++ )
cout << a[i] <<" ";
}

I tried it and I haven't got any problem yet. Is/Will there be a problem with my code.

It's a bubble sort right?