Cod sursa(job #1222138)

Utilizator space.foldingAdrian Soucup space.folding Data 22 august 2014 12:29:56
Problema Sortare prin comparare Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.7 kb
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main () {
#ifndef ONLINE_JUDGE
    freopen("algsort.in", "r", stdin);
    freopen("algsort.out", "w", stdout);
#endif //ONLINE_JUDGE

	cin.sync_with_stdio(false);
	cout.sync_with_stdio(false);

	string input;
	getline(cin, input, '\0');


	istringstream fin(input);
	ostringstream fout;

	int n;

	fin >> n;

	vector<int> v(n);

	for (int i = 0; i < n; i++)
		fin >> v[i];

	input.swap(string());
	fin.swap(istringstream());

	sort(v.begin(), v.end());


	for (int i = 0; i < n; i++) {
		fout << v[i] << " ";
	}
	
	cout << fout.str();
    return 0;
}