Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- #include <fstream>
- #include <set>
- using namespace std;
- int main()
- {
- ifstream fin("intrare.txt");
- ofstream fout("iesire.txt");
- if (!fin.is_open())
- {
- cout << "Nu s-a gasit fisierul.";
- return -1;
- }
- set<string> mySet;
- set<string>::iterator mySetIterator;
- string cuvant, linie;
- while (!fin.eof())
- {
- getline(fin, linie);
- stringstream ss(linie);
- while (!ss.eof())
- {
- ss >> cuvant;
- mySet.insert(cuvant);
- }
- }
- for (mySetIterator = mySet.begin(); mySetIterator != mySet.end(); ++mySetIterator)
- {
- fout << *mySetIterator << " ";
- }
- fin.close();
- fout.close();
- cout << "Gata. verifica fisierul.";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment