Cod sursa(job #1702455)

Utilizator xtreme77Patrick Sava xtreme77 Data 15 mai 2016 11:24:15
Problema Sortare prin comparare Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <fstream>
#include <algorithm>

using namespace std;

int v [ 600000 ] ;

struct cmp {
    bool operator () ( const int a , const int b ) const
    {
        return a < b ;
    }
};

bool cmp2 ( int a , int b )
{
    return a < b ;
}

ifstream cin ( "algsort.in" ) ;
ofstream cout ( "algsort.out" ) ;

int main()
{
    int n ;
    cin >> n ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        cin >> v [ i ] ;
    }
    //sort ( v + 1 , v + n + 1 , cmp ( ) ) ;
    sort ( v + 1 , v + n + 1 , cmp2 ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        cout << v [ i ] << ' ' ;
    }
    return 0;
}