Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <thread>
- #include <iostream>
- #include <vector>
- #include <numeric>
- #include <fstream>
- std::ofstream plik_wyj("plik.txt");
- bool odnaleziono = false;
- void search_tab(const std::vector<int> &tab, int poc, int kon, int szuk)
- {
- for (int i = poc; i < kon; i++)
- {
- if (odnaleziono == true)
- {
- break;
- }
- if (tab[i] == szuk)
- {
- plik_wyj << "odnaleziono" << std::endl;
- odnaleziono = true;
- break;
- }
- }
- }
- int main()
- {
- std::vector<int> tab(200);
- std::iota(tab.begin(), tab.end(), 1);
- int x = 0;
- for (int i = 0, j = 25; i < 200; i += 25, j += 25)
- {
- std::thread th(&search_tab, tab, i,j,100);
- plik_wyj << "TH: " << th.get_id() << std::endl;
- th.detach();
- }
- if (odnaleziono == false)
- plik_wyj << "nie odnaleziono";
- std::cin.ignore(20);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement