Advertisement
dxvmxnd

Untitled

Dec 6th, 2023
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <set>
  4.  
  5. using namespace std;
  6.  
  7. set<string> getPossibleVocabulary() {
  8.  
  9.  
  10. set<string> vocabulary = {};
  11. string path = "C:\\Users\\Рустамчик\\Desktop\\опишка\\input.txt";
  12. string word = "";
  13.  
  14.  
  15. ifstream fin(path);
  16. if (!fin.is_open()) {
  17. printf("Какая-то ошибка с файлом.");
  18. }
  19. else {
  20. while (fin >> word) {
  21. vocabulary.insert({ word });
  22. }
  23. }
  24. fin.close();
  25.  
  26. return vocabulary;
  27.  
  28. }
  29.  
  30. set<string> addNewWord(string line) {
  31.  
  32. set<string> vocabulary = {};
  33. string path = "C:\\Users\\Рустамчик\\Desktop\\опишка\\input.txt";
  34. string word = "";
  35.  
  36. ofstream fout(path, fstream::app);
  37. fout << "\n" << line;
  38. fout.close();
  39.  
  40.  
  41. ifstream fin(path);
  42. if (!fin.is_open()) {
  43. printf("Какая-то ошибка с файлом.");
  44. }
  45. else {
  46. while (fin >> word) {
  47. vocabulary.insert({ word });
  48. }
  49. }
  50. fin.close();
  51.  
  52. return vocabulary;
  53.  
  54.  
  55. }
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement