Advertisement
luizaspan

Rand II

Jun 2nd, 2015
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h> // rand() ou random()
  3.  
  4. #define n 100
  5.  
  6. int main(void)
  7. {
  8.   int i,a[n];
  9.   double x[100];
  10.  
  11.   // gerando nova sequencia de numeros aleatórios:
  12.   srand(218739);
  13.      
  14.   for (i=0;i<100;i++)
  15.     {
  16.       x[i]=(double) rand()/RAND_MAX;
  17.       a[i]=rand()%n +1;
  18.       a[i]=(double) rand()/RAND_MAX*n;
  19.  
  20.       printf("%lf\t %d \n",x[i],a[i]);      
  21.     }
  22.      
  23.   // RAND_MAX definido no <stdlib.h>
  24.   // número aleatório entre 1 e RAND_MAX
  25.      
  26.   return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement