Advertisement
newvol

NOOOO THE THREAD... ITS not WORKING

Jun 11th, 2023
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. #include <thread>
  4.  
  5. using namespace std;
  6.  
  7. void count_dividers(list<int> List) {
  8.   int sum = 0, count = 0;
  9.   for (auto it = List.begin(); it != List.end(); it++) {
  10.     sum += *it;
  11.   }
  12.   for (auto it = List.begin(); it != List.end(); it++) {
  13.     if (sum % *it == 0) {
  14.       count++;
  15.     }
  16.   }
  17.   cout << count << endl;
  18. }
  19.  
  20. int main() {
  21.   list<int> mylist;
  22.  
  23.   int n;
  24.   cin >> n;
  25.  
  26.   for (int i = 0; i < n; i++) {
  27.     int temp;
  28.     cin >> temp;
  29.     mylist.push_back(temp);
  30.   }
  31.  
  32.   thread aboba([=] {
  33.     count_dividers(mylist);
  34.   });
  35.   aboba.join();
  36.   aboba.detach();
  37.   return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement