Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set<int> getSetFromFile(string path) {
- bool isCorrect;
- string temp;
- set<int> arr[3];
- int num, size;
- //int size = getSizeForSetFromFile(path);
- ifstream fin;
- isCorrect = true;
- fin.open(path);
- for (int i = 0; i < 3; i++) {
- do {
- isCorrect = true;
- fin >> size;
- if (fin.fail()) {
- isCorrect = false;
- fin.clear();
- cout << "Check the correctness of the entered data from the file.\n";
- path = getPath();
- }
- if (isCorrect && (size > 15 || size < 1)) {
- isCorrect = false;
- cout << "check the correctness of the entered data from the file.\n";
- path = getPath();
- }
- } while (!isCorrect);
- //fin >> temp;
- for (int j = 0; j < size; j++) {
- do {
- isCorrect = true;
- fin >> num;
- if (fin.fail()) {
- isCorrect = false;
- cout << "Invalid data in the file.\n";
- path = getPath();
- }
- } while (!isCorrect);
- arr[i].insert(num);
- }
- }
- fin.close();
- return arr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement