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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

}<br />

/* ...continua */<br />

srand(seme);<br />

for (i = 0; i < n; i++) {<br />

a = 1 + rand() % 6;<br />

b = 1 + rand() % 6;<br />

printf("%d %d\n", a, b);<br />

}<br />

return 0;<br />

inizializzazione del seme<br />

un ciclo per ogni lancio<br />

primo dado<br />

secondo dado<br />

stampa il risultato<br />

il programma legge da linea <strong>di</strong> comando il seme e il numero <strong>di</strong><br />

lanci da effettuare, rispettivamente in questo or<strong>di</strong>ne; Se i parametri<br />

non vengono forniti, sono usati i valori <strong>di</strong> default<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!