Advertisement
SmnVadik

Untitled

Dec 7th, 2022
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. set<int> getSetFromFile(string path) {
  2.     bool isCorrect;
  3.     string temp;
  4.     set<int> arr[3];
  5.     int num, size;
  6.     //int size = getSizeForSetFromFile(path);
  7.     ifstream fin;
  8.     isCorrect = true;
  9.     fin.open(path);
  10.  
  11.     for (int i = 0; i < 3; i++) {
  12.         do {
  13.             isCorrect = true;
  14.             fin >> size;
  15.             if (fin.fail()) {
  16.                 isCorrect = false;
  17.                 fin.clear();
  18.                 cout << "Check the correctness of the entered data from the file.\n";
  19.                 path = getPath();
  20.             }
  21.             if (isCorrect && (size > 15 || size < 1)) {
  22.                 isCorrect = false;
  23.                 cout << "check the correctness of the entered data from the file.\n";
  24.                 path = getPath();
  25.             }
  26.         } while (!isCorrect);
  27.  
  28.         //fin >> temp;
  29.         for (int j = 0; j < size; j++) {
  30.             do {
  31.                 isCorrect = true;
  32.                 fin >> num;
  33.                 if (fin.fail()) {
  34.                     isCorrect = false;
  35.                     cout << "Invalid data in the file.\n";
  36.                     path = getPath();
  37.                 }
  38.             } while (!isCorrect);
  39.             arr[i].insert(num);
  40.         }
  41.     }
  42.     fin.close();
  43.     return arr;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement