Cod sursa(job #2285604)

Utilizator sabinpocrisSabin P sabinpocris Data 18 noiembrie 2018 19:54:04
Problema Sortare prin comparare Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.62 kb
#include <bits/stdc++.h> 
using namespace std;

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

void getNumbers(vector<int> &v){
	string temp;
	int nr, processing = 0;
	const char *c;

	getline(in, temp);

	c = temp.c_str();
	while(*c != '\0'){
		nr = 0;
		processing = 0;
		while (*c >= '0' && *c <= '9'){
			processing = 1;
			nr = nr * 10 + (*c - '0');
			c++;
		}

		if (processing){
			v.push_back(nr);
		}

		c++;
	}
}


int main(){
	string temp;
	vector<int> numbers;
	
	getline(in, temp);
	getNumbers(numbers);
	
	sort(numbers.begin(), numbers.end());

	for (auto item : numbers)
		out << item << " ";

	return 0;
}