26 vector<string> in_files;
27 for (
const auto &entry : filesystem::directory_iterator(filesystem::current_path()))
29 if (entry.is_regular_file())
31 string filename = entry.path().filename().string();
32 if (filename.size() >= 3 && filename.substr(filename.size() - 3) ==
".in")
34 in_files.push_back(filename);
42 cout <<
"No .in files found in the current directory." << endl;
45 else if (in_files.size() == 1)
47 selected_file = in_files[0];
48 cout <<
"Found one .in file: " << selected_file <<
". Automatically selecting it." << endl;
52 cout <<
"Multiple .in files found. Please select one:" << endl;
53 for (
size_t i = 0; i < in_files.size(); i++)
55 cout << i + 1 <<
". " << in_files[i] << endl;
61 cout <<
"Enter the number of the file you want to use (1-" << in_files.size() <<
"): ";
64 if (cin.fail() || file_choice < 1 || file_choice >
static_cast<int>(in_files.size()))
67 cin.ignore(numeric_limits<streamsize>::max(),
'\n');
68 cout <<
"Invalid input. Please enter a number between 1 and " << in_files.size() <<
"." << endl;
75 selected_file = in_files[file_choice - 1];