Advertisement
35657

Untitled

Apr 30th, 2024
614
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <iostream>
  4. #include <string>
  5. #include <fstream>
  6. #include <filesystem>
  7. #include <windows.h>
  8.  
  9.  
  10. using namespace std;
  11.  
  12. void find_all(const string& find_name, const string& catalogue) {
  13.     for (const auto& a : filesystem::directory_iterator(catalogue)) {
  14.         string name = a.path().filename().string();
  15.         string full_name = catalogue + '/' + name;
  16.         if (name.find(find_name) != string::npos) {
  17.             cout << full_name << endl;
  18.         }
  19.         if (filesystem::is_directory(full_name)) {
  20.             find_all(find_name, full_name);
  21.         }
  22.     }
  23. }
  24.  
  25. int main() {
  26.  
  27.     SetConsoleCP(1251); // установка кодировки 1251 в поток ввода
  28.     SetConsoleOutputCP(1251); // установка кодировки 1251 в поток вывода
  29.  
  30.     find_all("Задания", "C:/Users/PC/Desktop/Основы программирования С++");
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement