Originally Posted by
phantomotap
Code:
copy(issi(cin), issi(), bi(data));
sort(data.begin(), data.end(), [](const string & l, const string & r) {l.length() < r.length()});
copy(data.begin(), data.end(), ossi(cout, "\n"));
Ctrl + Z in new line?
Ok. Let me show this code.
Code:
#include <iostream>
#include <iterator>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
struct CompareString
{
bool operator()(const string &l, const string &r)
{return (l.length() < r.length());}
};
int main()
{
vector<string> data;
copy(istream_iterator<string>(cin), istream_iterator<string>(), back_inserter(data));
sort(data.begin(), data.end(), CompareString());
copy(data.begin(), data.end(), ostream_iterator<string>(cout, "\n"));
return 0;
}