Cod sursa(job #936270)

Utilizator AnduuFMI Alexandru Banu Anduu Data 6 aprilie 2013 14:58:50
Problema Sortare prin comparare Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.64 kb
#include <fstream>
#include <algorithm>
using namespace std;
int n, v[500001], i;
void citire ()
{
    ifstream in ("algsort.in");
    in >> n;
    for (i = 1; i <= n; ++i)
    in >> v[i];
    in.close ();
}
/* void sort ()
{
    int 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;
    }
} */
void afis ()
{
    ofstream out ("algsort.out");
    for (i = 1; i <= n; ++i)
    out << v[i];
    out << '\n';
    out.close ();
}
int main()
{
    citire ();
    sort (v + 1, v + n + 1);
    afis ();
    return 0;
}