Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <pthread.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5.  
  6. int radius = 100;
  7. int Cnum_of_points;
  8.  
  9.  
  10. typedef struct // tuple structure
  11. {
  12. int x, y;
  13. } Tuple;
  14.  
  15. const int MAXSIZE = 50000000;
  16. Tuple nums[MAXSIZE];
  17. int Tnum_of_points = 0;
  18.  
  19. void new_point() // generate a new tuple
  20. {
  21.  
  22. int x = (rand() % (radius+1-0))+0;
  23. int y = (rand() % (radius+1-0))+0;
  24. Tuple a;
  25. a.x = x;
  26. a.y = y;
  27.  
  28. if (Tnum_of_points < MAXSIZE)
  29. {
  30. nums[Tnum_of_points] = a;
  31. ++Tnum_of_points;
  32. }
  33. else
  34. {
  35. // pass -- full
  36. }
  37.  
  38. }
  39.  
  40. int main()
  41. {
  42.  
  43. printf("size of nums: %d\n", Tnum_of_points);
  44. new_point();
  45. printf("size of nums: %d\n", Tnum_of_points);
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement