Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <pthread.h>
  4.  
  5. int fib(int n)
  6. {
  7. if ( n == 0 )
  8. {
  9. return 0;
  10. }
  11. if ( n == 1 )
  12. {
  13. return 1;
  14. }
  15.  
  16. if ( n > 1)
  17. {
  18. return ( fib(n-1) + fib(n-2) );
  19. }
  20.  
  21. }
  22.  
  23. void *wyswietl()
  24. {
  25. int x,n;
  26. scanf("%i",&n);
  27. x = fib(n);
  28. printf("%i",x);
  29. printf("\n");
  30. }
  31.  
  32. void *postep()
  33. {
  34. while (1>0)
  35. {
  36. usleep(1000000);
  37. printf(".");
  38. }
  39.  
  40. }
  41.  
  42.  
  43. int main()
  44. {
  45. pthread_t thread1, thread2;
  46. int iret1, iret2;
  47. iret1 = pthread_create( &thread1, NULL, wyswietl, (void *) NULL);
  48. iret2 = pthread_create( &thread2, NULL, postep, (void *) NULL);
  49. pthread_join(thread1,NULL);
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement