Xiaoxiao comparte programación
#¿Incluir? & ltiostream & gt
#Contiene? & ltctime & gt
#¿Contiene? & ltcstdlib & gt
¿Usar? ¿Espacio de nombres? std
¿Doble? getRand(¿doble? uno,? ¿doble? b)
{
¿Retorno? (licenciado en Letras)? *?(doble)rand()? /?RAND_MAX? +?a;
}
int? main(int?argc,?char?*argv[])
{
¿Doble? uno,? b;? int? ¿metro? =?0,?n? =?100000;
srand(time(NULL));
printf("a?=?");? scanf("%lf ",&a);? printf("b?=?");? scanf("%lf ",& ampb);?
for(int?i?=?0;?i?<?n;?++i)
{
¿Doble? ¿incógnita? =?getRand(-a, a);
¿Doble? ¿y? =?getRand(-b,?b);
If (x?*?x?/?answer?/?answer?+?y?*?y?/?b?/?b? & lt=?1.0)
{
m? +=?1;
}
}
printf("%f\n ", 4.0?*?m?/?n); p> p>
¿Volver? 0;
}