Advertisement
nex036ara

njakanje_niti

Mar 28th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <thread>
  4. using namespace std;
  5.  
  6. void f(vector<double>::reverse_iterator it) {
  7.         cout<< *it<<" ";
  8.         }
  9.  
  10. int main()
  11. {
  12.     int n;
  13.  
  14.     cout<<"Unesi n: "<<endl;
  15.     cin>>n;
  16.  
  17.     vector<double> v(n);
  18.     thread niti[n];
  19.  
  20.     cout<<"Unos elemenata: "<<endl;
  21.     for(int i=0; i<n; ++i) {
  22.     cin>> v[i];
  23.     }
  24.  
  25. int i=0;
  26.     for(auto it=v.rbegin(); it!=v.rend(); ++it,++i) {
  27.          niti[i] = thread(f,it);
  28.  
  29.     }
  30.  
  31.     for(int i=0; i<n; ++i){
  32.     niti[i].join();
  33.     }
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement