rabbitekk312

Serwer

Dec 14th, 2020 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <pthread.h>
  3. #define N 3    
  4.  
  5. int main(){
  6.     int A[N][N];
  7.     pthread_t serwer[N], klient;
  8.  
  9.     printf("Podaj macierz %dx%d\n", N, N);
  10.     for(int i = 0; i < N; i++)
  11.         for(int j = 0; j < N; j++)
  12.             scanf("%d", &A[i][j]);
  13.  
  14.     for(int i = 0; i < N; i++)
  15.         pthread_create(&serwer[i], NULL, serwer, &A[i]);
  16.  
  17.     pthread_create(&klient, NULL, klient, NULL);
  18.  
  19. }
  20. void serwer(void *wektor)
  21. {
  22.     int wynikowe=0;
  23.     int asd=(int*)wektor;
  24.     for (int i=0; i<N; i++)
  25.     {
  26.         wynikowe+=asd;
  27.     }
  28. }
  29.  
  30.  
Add Comment
Please, Sign In to add comment