mercoledì 21 ottobre 2009

LancioDado

#include
#include
int seed=10000
int M=5;
int y;
int z;
int i;
double r;
double x;
public int lanciDado(){
r=( (double) rand() )/ ((double) (RAND_MAX+(double)(1)));
x=(r*M);
y=(int) x;
z=y+1;
return z;
}
main(){
int n;
srand(seed);
for (i=0; i<50; i++){
n=lancioDado();
printf("%d\n",n);
}
}

Nessun commento: