Pagini recente » Cod sursa (job #716148) | Cod sursa (job #1140765) | Cod sursa (job #2611330) | Cod sursa (job #996726) | Cod sursa (job #712561)
Cod sursa(job #712561)
#include <fstream>
using namespace std;
fstream fin("algsort.in",ios::in),fout("algsort.out",ios::out);
void sortare(long long v[99999],long long n)
{
long long ok=1,i,aux;
do
{
ok=1;
for (i=1;i<n;i++)
{
if (v[i]>v[i+1])
{
aux=v[i];
v[i]=v[i+1];
v[i+1]=aux;
ok=0;
}
}
}while (ok==0);
}
int main()
{
long long n,i,x[99999];
fin>>n;
for (i=1;i<=n;i++)
{
fin>>x[i];
}
sortare(x,n);
for (i=1;i<=n;i++)
{
fout<<x[i]<<" ";
}
return 0;
fin.close();
fout.close();
return 0;
}