Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define D 6
- #define N 100000000
- int main(){
- int dado[D+1], i;
- clock_t ti, tf;
- double dif;
- srand(time(NULL));
- ti=clock();
- for( i=1 ; i<D+1 ; i++ )
- dado[i]=0;
- for( i=0 ; i<N ; i++ )
- dado[rand()%D+1]++;
- for( i=1 ; i<D+1 ; i++ )
- printf(" %d esta repetido %d veces \n",i,dado[i]);
- tf=clock();
- dif = ((double)tf - (double) ti) / CLOCKS_PER_SEC;
- printf(" %d numeros pseudoaleatorios en %f segundos \n ",N,dif);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement