void task3() {
ifstream slovar;
slovar.open("slovar.txt");
ofstream out;
out.open("output.txt");
list<string> lines;
while (!slovar.eof())
{
string s1;
getline(slovar, s1, '\n');
lines.push_back(s1);
}
lines.sort();
//lines.erase(unique(lines.begin(), lines.end()), lines.end());
copy(lines.begin(), lines.end(), ostream_iterator<string>(out, "\n"));
slovar.close();
out.close();
}
//lines.erase(unique(lines.begin(), lines.end()), lines.end());
auto in = ifstream("in.txt");
auto out = ofstream("out.txt");
list<string> ls;
copy(istream_iterator<string>(in), {}, back_inserter(ls));
ls.sort();
ls.unique();
copy(ls.begin(), ls.end(), ostream_iterator<string>(out, "\n"));
#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
void task3() {
ifstream slovar;
slovar.open("slovar.txt");
ofstream out;
out.open("output.txt");
vector<string> lines;
while (!slovar.eof())
{
string s1;
getline(slovar, s1, '\n');
lines.push_back(s1);
}
sort(begin(lines), end(lines));
set<string> linesSet(begin(lines), end(lines));
for (auto& str : linesSet) {
out << str << endl;
}
slovar.close();
out.close();
}
basds
sdsdsds
sdsdsdssdsds
asdasdsad
basds
basds
sdsdsdssdsds
asdasdsad
basds
sdsdsds
sdsdsdssdsds