Exemple #1
0
int main(void)
{

  double soma = 0;
  int pi, count = 0;
  long seed = time(NULL);
  srand((unsigned)seed);
  for ( pi = 0; pi<1000; pi++)
  {
    if ( realRandom() <  coseno())
    	count++;
  }

  printf("Valor de PI: %lf\n", 2.0 * (double)pi /(1.0 * count));

}
void Elevator::planRepair()
{
    QTimer::singleShot( realRandom() % 10000, this, SLOT(onRepair()) );
}
void Elevator::planArrival()
{
    QTimer::singleShot( realRandom() % 7000, this, SLOT(onArrival()) );
}
void Elevator::planLeave(double coef)
{
    double editedCoef = coef + ( (((realRandom() % 9) - 4) / 10.0) * coef );
    mLeaveTimer.start(editedCoef);
}