#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

bool less_size(const string& s1, const string& s2) {
	return s1.size()<s2.size();
}

int main() {
	ifstream in("webster_unsorted.txt");
	if (in) {
		ofstream out("webster.txt");
		istream_iterator<string> inbegin(in);
		istream_iterator<string> inend;
		ostream_iterator<string> outbegin(out, "\n");
		vector<string> v;
		copy(inbegin, inend, back_inserter(v));
		if (v.size()>0) {
			sort(v.begin(), v.end());
			copy(v.begin(), v.end(), outbegin);
			cout<<"Maximale woordlengte: "<<max_element(v.begin(), v.end(), less_size)->size()<<endl;
		}
		cout<<"Aantal woorden: "<<v.size()<<endl;
	}
	cout<<"Kan webster_unsorted.txt niet openen!"<<endl;
	cin.get();
	return 0;
}

