Cod sursa(job #2262495)
| Utilizator | Data | 17 octombrie 2018 14:58:32 | |
|---|---|---|---|
| Problema | Sortare prin comparare | Scor | 40 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include <fstream>
using namespace std;
ifstream fin("algsort.in");
ofstream fout("algsort.out");
#define NMAX 500001
int n,v[NMAX];
void citire()
{ fin>>n;
int i;
for(i = 1; i <= n; i++)
fin>>v[i];
}
void rezolvare()
{citire();
int i,j,aux;
for(i = 1; i < n; i++)
for(j = i+1; j <= n; j++)
if(v[i] > v[j])
{aux = v[i];
v[i] = v[j];
v[j] = aux;
}
for(i = 1; i <= n; i++)
fout<<v[i]<<' ';
}
int main()
{
rezolvare();
fin.close();
fout.close();
return 0;
}
