Advertisement
everblut

srand()

Mar 20th, 2011
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. //generando numeros aleatorios con semilla
  2. #include <stdio.h>
  3. #include <time.h>
  4.  
  5. int main(int argi,char** args){
  6.   int iterador=0;
  7.   int x=0;
  8.   int semilla;
  9.  
  10.   srand(time(NULL)); /* time(null) nos dara el tiempo transcurrido en segundos
  11.             desde epoch.
  12.               */
  13.  
  14.   for(iterador = 0; iterador < 10; iterador++){
  15.     x = (rand()%20+10);
  16.     printf("Aqui esta el %d numero del random: %d \n",iterador,x);
  17.   }
  18.  
  19.   return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement