Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include "winbgi2.h"
  4. #include <stdlib.h>
  5. #include <time.h>
  6. #define N (10)
  7. #define Lx (500)
  8. #define Ly (500)
  9.  
  10. int i;
  11. void init (double *x, double *y, double *vx, double *vy);
  12. void display (double *x, double *y);
  13.  
  14. void main()
  15. {
  16. srand(time(NULL));
  17. graphics (Lx,Ly);
  18. double x[N], y[N];
  19. double vx[N], vy[N];
  20. init (x, y, vx, vy);
  21. display (x, y);
  22. }
  23.  
  24. void init(double *x, double *y, double *vx, double *vy)
  25.  
  26. {
  27. int predkosc = 1;
  28. int max_x = Lx;
  29. int max_y = Ly;
  30. int L_x = max_x+1;
  31. int L_y = max_y+1;
  32.  
  33. for (i=0; i<N; i++)
  34. {
  35. double angle = (double)(rand() % 360) * PI / 180.0;
  36. x[i]=rand()%L_x;
  37. y[i]=rand()%L_y;
  38. vx[i]=predkosc * cos(angle);
  39. vy[i]=predkosc * sin(angle);
  40. }
  41. }
  42.  
  43. void display(double *x,double*y)
  44. {
  45. for(i=0;i<N;i++)
  46. {
  47. circle (x[i], y[i], 10);
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement