18.08.2013 Views

Fondamenti di Informatica Librerie di funzioni - Robotica

Fondamenti di Informatica Librerie di funzioni - Robotica

Fondamenti di Informatica Librerie di funzioni - Robotica

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Generazione <strong>di</strong> numeri casuali<br />

rand() ritorna un numero pseudo-casuale compreso<br />

nell’intervallo [0, RAND MAX]<br />

• e’ semplice ottenere un numero pseudo-casuale in un qualsiasi<br />

intervallo [a, b]<br />

• si utilizza opportunamente l’operatore modulo<br />

valore = a + rand() % (b - a + 1);<br />

Tullio Facchinetti <strong>Fondamenti</strong> <strong>di</strong> <strong>Informatica</strong> <strong>Librerie</strong> <strong>di</strong> <strong>funzioni</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!