Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include "winbgi2.h"
- #include <stdlib.h>
- #include <time.h>
- #define N (10)
- #define Lx (500)
- #define Ly (500)
- int i;
- void init (double *x, double *y, double *vx, double *vy);
- void display (double *x, double *y);
- void main()
- {
- srand(time(NULL));
- graphics (Lx,Ly);
- double x[N], y[N];
- double vx[N], vy[N];
- init (x, y, vx, vy);
- display (x, y);
- }
- void init(double *x, double *y, double *vx, double *vy)
- {
- int predkosc = 1;
- int max_x = Lx;
- int max_y = Ly;
- int L_x = max_x+1;
- int L_y = max_y+1;
- for (i=0; i<N; i++)
- {
- double angle = (double)(rand() % 360) * PI / 180.0;
- x[i]=rand()%L_x;
- y[i]=rand()%L_y;
- vx[i]=predkosc * cos(angle);
- vy[i]=predkosc * sin(angle);
- }
- }
- void display(double *x,double*y)
- {
- for(i=0;i<N;i++)
- {
- circle (x[i], y[i], 10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement