Programación con lenguaje c del juego de monedas
Hay un problema con su programa, srand(time(NULL)); debe colocarse fuera de la declaración del bucle for. El prototipo de función de tiempo está en time.h,
Código fuente modificado:
# incluir & ltstdio.h & gt
# incluir & ltstdlib.h & gt
# incluir & lttime.h & gt
int voltear (vacío);
int main()
{
int a=0, b=0, x, k;
srand(tiempo(NULL));
for(x = 1; x & lt=100;x++)
{
k = flip()
If (k==1)
{
printf("Cabeza.\n ");
a++;
p>
}
Otros
{
printf("Tails.\ n ");
b++;
p>
}
}
Printf("Tiempos positivos: %d\n ",
Printf("Tiempos negativos: % d\n ", b);
System("pausa");
Devuelve 0; }
Volteo interno (no válido)
{
return(rand()% 2);
}
Esto es lo que ejecuté en VS.