Cod sursa(job #1460883)

Utilizator bublesbubles tiganu bubles Data 14 iulie 2015 11:41:39
Problema Sortare prin comparare Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
#include <fstream>
#include <stdlib.h>

using namespace std;
ifstream fin("algsort.in");
ofstream fout("algsort.out");

int compare(const void * a, const void * b){
    return ( *(int*)a - *(int*)b );
}

int main(){
    unsigned int n, v[500001];
    fin >> n;
    for(int i = 0; i < n; i++){
        fin >> v[i];
    }
    qsort (v, 6, sizeof(unsigned int), compare);
    for(int i = 0; i < n; i++){
        fout << v[i] << " ";
    }
    return 0;
}