Advertisement
jeicamad

Untitled

May 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. //watki
  2. for (int k = 0; k < i; k++)
  3. {
  4. tab[k][j] = k;
  5. if (thr_create(NULL, 0, suma, tab[k], 0, NULL) == 0)
  6. cout << "Utworzono watek " << endl;
  7. else
  8. cout << "Nie udalo sie utworzyc watku" << endl;
  9. }
  10.  
  11. while (thr_join(0, NULL, NULL) == 0);
  12.  
  13. double srednia = sum / i;
  14. cout << "Srednia: " << srednia << endl;
  15. }
  16.  
  17. void * suma(void *arg)
  18. {
  19. int suma = 0;
  20. int *p = (int*)arg;
  21.  
  22. for (int w = 0; w<j; w++){
  23. suma += p[w];
  24. }
  25.  
  26. cout << "Wynik dla wiersza " << p[j] + 1 << endl;
  27. cout << suma << endl;
  28. sum += suma;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement