Cod sursa(job #2623777)
| Utilizator | Data | 3 iunie 2020 19:50:18 | |
|---|---|---|---|
| Problema | Sortare prin comparare | Scor | 40 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
using namespace std;
int a[500001], n, aux;
int main()
{ifstream in ("algsort.in");
ofstream out("algsort.out");
in >> n;
for (int i = 0 ; i < n; ++i)
in >>a[i];
for (int i = 0 ; i < n-1; ++i)
for (int j = i + 1 ; j < n; ++j)
if(a[i] > a[j]){
aux = a[i];
a[i] = a[j];
a[j] = aux;
}
for (int i = 0; i < n ; ++i)
out << a[i] << ' ';
}
