Cod sursa(job #1655087)

Utilizator andreigasparoviciAndrei Gasparovici andreigasparovici Data 17 martie 2016 18:42:01
Problema Sortare prin comparare Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.41 kb
#include <fstream>
#include <cstdlib>
using namespace std;
int a[500001],n;
int compare (const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}
int main()
{
    ifstream fin("algsort.in");
    ofstream fout("algsort.out");
    fin>>n;
    for(int i=0;i<n;i++)
        fin>>a[i];
    qsort (a, n, sizeof(int), compare);
    for(int i=0;i<n;i++)
        fout<<a[i]<<' ';
    return 0;
}