Advertisement
cd62131

Random

Feb 9th, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(void) {
  4.   int i,num = 500;
  5.   double x[num];
  6.   double y[num];
  7.   srand(149);
  8.   for (i = 0; i < num; i++) {
  9.     x[i] = -5.0 + ((double) rand()) / RAND_MAX * 10.0;
  10.     y[i] = -5.0 + ((double) rand()) / RAND_MAX * 10.0;
  11.     if (x[i] * x[i] + y[i] * y[i] > 25.0) i--;
  12.   }
  13.   for (i = 0; i < num; i++)
  14.     printf("% g % g % g\n", x[i], y[i], x[i] * x[i] + y[i] * y[i]);
  15.   return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement